Skip to main content

Azure Blob file download not resuming !

Azure Blobs are a scalable infrastructure to host\store files. I was working on understanding the behavior of large file uploads and downloads and create a reasonable strategy to support both scenarios in our application.

Azure blob file can be downloaded using any browser or internet download manager. For a public blob the url of file would suffice, but for downloading a private blob one needs to create a url containing the Secured Access Signature.

While testing downloads I realized that in case I pause and resume the download in Firefox or Chrome or any download manager the download restarts !!! I was expecting that the download should start from the place it paused. Imagine the scenario where we have uploaded half of a 2GB file and resuming the download would start over again !!! Clearly the Azure Blob storage was not supporting HTTP Range header.

As it turns out the Azure blob service is not a trivial file server. It is more of a Storage Application Server. It exposes an REST API to interact with it. The ability to support Range header(hence resume) was added in a later version of  Blob API.

The default API version that we interact with is 2009-09-19. This is the version used in case we do not specify any (version can be added in HTTP header x-ms-version). Since the browser does not send any custom version header while making the GET request we do not get the resume support.

The fix here was to update the blob service properties for our account using the Set Blob Service Properties API method. This method takes a parameter DefaultServiceVersion. This parameter defines the default version of blob API to use in case API version is not specified in the HTTP header. Setting this value to 2011-08-18 fixed the resume problem.

Now the browser was able resume broken downloads and download managers could even download in multiple chunks to improve download speed.

I did not find any option in the Azure Management portal that allows us to set the the above property so I had to do it using the REST API. I am sharing the code that I used to update the API version below


Eslam Hamouda said…
this code should work after the new changes to Azure assemblies :

var account = CloudStorageAccount.Parse("ConnectionString");
var blobs = account.CreateCloudBlobClient();
var existingprops = blobs.GetServiceProperties();
blobs.SetServiceProperties(new Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties()
DefaultServiceVersion = "2011-08-18",
Logging = existingprops.Logging,
Metrics = existingprops.Metrics,

Thanks :)
chandermani said…
Thanks for sharing the information :)

Popular posts from this blog

Caching Images downloaded from web on Windows Phone Isolated storage

I was helping on a Windows Phone application where the requirement was to cache the images the phone downloads on the isolated storage for offline viewing.
I wanted a solution which was simple and as transparent as possible. While researching I found  someone wrote a Silverlight converter for loading images from isolated storage. Taking that as a base I created a converted which can
Load image from web (http + https), and persist it to isolated storage.In case of network connectivity issues can load the same image from isolated storage. It does that by mapping the http url to a isolated storage location.In case the network is down and the image is neither there in cache, loads a default image, passed as parameter to converter.Here is the gist for the implementation.

To use the converter
Import the name space.Declare the converter as resource.Set the Image Source Property to use this converter like this 

AngularJS Model - ViewModel

Recently Robin Ward did a comparison between AngularJS and Ember (both the post and the comments are interesting read). One of the complaint that Robin had that AngularJS does not provide any specialized model class. As described in the blog

There is no standard Model base class, nor is there a component or interface in AngularJS that defines what a model is supposed to be.
What that means is that anything defined on $scope can acts as model, as this sample on the blog describes

For some (like me) this is the flexibility where as for others who want a more structural approach this is a nuisance.AngularJS does not even provide any definite guidelines around how the model should be actually designed to be effective with AngularJS

This leads to what we call as $scope pollution. We define multitude of properties on the $scope object and managing it becomes difficult.  Looking at the code one cannot tell what is the actual model and what properties are just to support UI logic.

Model Desig…