Trying out Windows Azure Storage

I am part of the team behind a set of web pages at where you can search for voice talents (people speaking in commercials, narrating documentaries etc.)

One of the features of these sites, is that you get to listen to some of the work, these people have done before. This means we have a lot of mp3-files stored online at a web-hotel, and in the foreseeable future we will exceed the amount of space available. Therefore I have started to look at some alternatives – one of which is Windows Azure Storage.

I found this guide to get me started: (from now on: The Guide)

I had some problems however (the reason for this blog post). And I deviated from the guide in that I did not create a Windows Azure account – I simply used the built-in development test account, since I wanted to check out the programming model first. Also, you should note that in regard to The Guide mentioned above, I use .Net configuration, not Cloud Service.

NuGet or SDK? NuGet first…

The Guide says that I can get the relevant assemblies with NuGet, so I didn’t bother to get the SDK. I could write some code and get it to compile without too much trouble. When I wanted to test it I ran into problems.

Connection string for DevelopmentStore

First there was the connection string for azure. I use the following code to connect:

var connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
blobClient = storageAccount.CreateCloudBlobClient();

The default string looks like this:


When using the test account you can drop AccountName and AccountKey, and simply set UseDevelopmentStorage=true. I tried this:


This connection string does not parse. It turns out that the only thing in the connection string shall be UseDevelopmentStorage = true. (It is possible to add proxy-information as described in The Guide.)


NuGet or SDK? On second thought: SDK

Next I wanted to set up a container for our media files. I chose to call it “Media”:

container = blobClient.GetContainerReference("Media");
if (container.CreateIfNotExists())
                           new BlobContainerPermissions
                               PublicAccess = BlobContainerPublicAccessType.Blob

I could not connect to the server. When you are using the development test account you are supposed to connect to a storage emulator – and you don’t get the emulator with NuGet. So I also downloaded and installed the Windows Azure SDK. Then I had the Storage Emulator – you have to start it yourself from the start menu. Restarting my program, I could now connect to the server.

Container name

I immediately ran into the next problem. I received this error: “The remote server returned an error: (400) Bad Request”. It turns out that container names can only contain lowercase letters. So after changing “Media” to “media” it worked – I now have a container. The rest seems to be as described in The Guide – uploading, download, listing container contents and so on.

The structure of Azure Blob Storage:


When you use Azure Storage for real, you will make a named account, that will determine the URL where your files can be found:

http://<storage account><container>/<blob>


The container is somewhat like the root of a hard drive. You connect to the container before you do any blob manipulation,


The blob is simply data – like a file. The name of a blob can contain almost all characters, but should not end with . or / or a combination of these. The URI for the file is created using the .Net URI class and this will strip off these characters. But in general / is allowed as part of the blobs name (the filename).

This is because there is no directories in the containers data structure. So the answer to one of my first questions: How do you create a directory in Azure Storage, is: You don’t. There is no such thing as a directory. But to create structure you can name your blobs like this “MySimulatedDir/MyBlob”.

This section of The Guide show how to list all the files in the container like they are in a directory structure, by using virtual folders.

About Lund

Owner of iCodeIT, a software consulting company. I am primarily working the .NET development and architecture.
This entry was posted in C#, Cloud Computing, Windows Azure and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s