x-ms-version and Azure Storage Services APIs
I have explained about x-ms-version in my previous post where I gave an example of Service Management APIs. Just to refresh, x-ms-version is a HTTP header which is used in Service Management API/ Azure Storage Services API calls to specify the version of operation. In other words users can specify which version of an operation they want to use by setting the x-ms-version request header. The benefit of x-ms-version is that if there is a new version of the API available, it will not break the functionality of your existing code. Users can modify the code to call a newer version of API by specifying the x-ms-version HTTP Headers.
In this blog post, I will demonstrate the use and impact of x-ms-version WITH Azure Storage Services API calls.
Default x-ms-version for Storage Service
In this example, I will simply use IE and browse the following URL:
https://storageaccount.blob.core.windows.net/testxmsversion?restype=container&comp=list
In this URL, testxmsversion is my container and comp=list is the command to list the blob in this container. Since I made this container public to simplify this scenario, thus I was able to access it right away from my Internet Explorer. Here is the response in IE where I could see that I got just one file HDD.jpg in this container.
Now let’s look at the request header. I am using Fiddler to inspect the request and response.
Accept: text/html,application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible;MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate, peerdist
Connection: Keep-Alive
Host: storageaccount.blob.core.windows.net
Pragma: no-cache
X-P2P-PeerDist:Version=1.0
Here is the response:
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 795cef3b-b8b8-4274-999f-78cf904f1060
x-ms-version: 2009-09-19
Date: Sun, 29 Sep 2013 04:50:06 GMT
If you closely look at the request headers, you would see that there is no mention of x-ms-version. But we could see x-ms-version is response. IE doesn’t know about x-ms-version thus it was not included. Since this header was missing, “2009-09-19” was considered the default version. You could set your own default x-ms-version. I will explain how to do this in my next blob post. Here is a link which shows currently available versions of storage services: https://msdn.microsoft.com/en-us/library/windowsazure/dd894041.aspx.
Let’s try to pass x-ms-version and inspects things:
For this example, I am going to use Fiddler to make a call. I will use the same request as shown in my previous example with an exception. Now I will pass x-ms-version as well. Here is the request headers:
User-Agent: Fiddler
Host: storageaccount.blob.core.windows.net
x-ms-version: 2009-07-17
This are the response headers I got after making the call:
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/xml
Server: Blob Service Version 1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 568392b5-f5a7-4437-a424-621da3ec3a27
Date: Sun, 29 Sep 2013 06:09:17 GMT
Here is response:
Points to note
So if you compare both the outputs, you will notice that query with x-ms-version: 2009-07-17 did not return any properties field.
If you also noticed the response headers Server, it was changed to Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 from Blob Service Version 1.0 Microsoft-HTTPAPI/2.0.