问题
The Azure table whitepaper mentions that the x-ms-request-id is useful to send to Microsoft in the event there is an error working with the data. If I do have such an error, I'd like my try...catch
block to take this and save it somewhere for future analysis.
In addition I need to extract the ETag value as well while in Table storage.
How do I extract this information and have it available when the Exception comes around?
HTTP/1.1 204 No Content
Content-Length: 0
ETag: W/"datetime'2008-10-01T15%3A27%3A34.4838174Z'"
x-ms-request-id: 7c1b5e22-831d-403c-b88a-caa4443e75cb
回答1:
Depends on your client implementation, but they are all HTTP 1.1 headers.
For example, ( Assuming .NET WebRequest Class ) something like:
WebRequest request = WebRequest.Create("http://myazurestore.server.com");
....
WebResponse response = request.GetResponse();
string mSRequestId = response.Headers["x-ms-request-id"];
Would work
EDIT(for Storage Client Lib) ...
If you are using the Client library, you can get at ETag from the Properties collection on CloudBlob
So ..
Cloudblob blob = container.GetBlobReference("blobname.ext");
var eTag = blob.Properties.ETag
Properties is a blobProperties object. It should provide access to most of the needed data.
MSDN: http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.blobproperties_members.aspx
回答2:
You may want to check out my open source Azure Table Storage Client project on CodePlex.
Lucifure Stash allows easy access to the ETag as well as the HttpWebRequest and HttpWebResponse objects.
来源:https://stackoverflow.com/questions/3746108/how-do-i-extract-etag-or-x-ms-request-id-from-my-astoria-datacontext-respons