Wednesday, January 9, 2013

Windows Azure: streaming videos from blob storage

Last week I discovered a nice feature of Windows Azure Blob storage. When you use Blob storage, you can change the API version. In the  2011-08-18 version of the Windows Azure Blob service, Microsoft  made some changes to improve browser download and streaming for some media players.

Before when you tried to play a video from blob storage, you had to download the whole file before you could start playing it. Starting from the 2011-08-18 version, you can do partial and pause/resume downloads on blob objects. The nice thing is that your client code doesn’t have to change to achieve this.

The only problem is that you have to set the version of the Blob storage(more info here).

I couldn’t find an easy way to specify the version, so in the end I wrote a small program:

var cloudStorageAccount = CloudStorageAccount
.Parse("DefaultEndpointsProtocol=https;AccountName={your account name};AccountKey={your account key}");

var client = cloudStorageAccount.CreateCloudBlobClient();
var prp = client.GetServiceProperties();

client.SetServiceProperties(new ServiceProperties()
{
DefaultServiceVersion = "2011-08-18",
Logging = prp.Logging,
Metrics = prp.Metrics
});

No comments: