开发者

How do I extract "eTag" or "x-ms-request-id" from my Astoria DataContext response?

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-b88开发者_JS百科a-caa4443e75cb


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜