«

»

Jun
30

Blob Storage – Part Two

Continuing our discussion on blob storage I thought it would be interesting if we looked at how blob storage can solve a perennial criticism of Azure, i.e. it is just to expensive to allow for hobbyists and individuals to use it. I have worked in the IT community for quite a will as an independent contractor and I know a lot of people within that community. A common requirement for contractors is to have a web site advertising thier skillset, portfolio and clients. Nine times out of ten, the site is static, there is absolutely no need for a data store, there are no financial transactions being pushed through the site and there is probably no need for video etc.

Quite often I hear members from this community state that Azure is to pricey, and for thier needs I have to agree. However I suspect that they are going down the route of having a web role (extra small instance), lets say 10 gb of storage and a CDN. Now give or take this is going to cost in the region of £26.50 or $47 a month. Straightaway there is no challenge in finding a cheaper equivalent offer by several orders of magnitude elsewhere… absolute no brainer.

However remember we are only wanting to serve up a static web site or silverlight application. Could blob storage come to our rescue ? Well we know that BLOB’s can be stored in a public container and are accessible via a public URI over an HTTP connection. The great thing about this storage mechanism is that it allows you to configure MIME types to ensure that the browser can correctly render the served content. We are going to look at hosting a static web site but its just as viable to serve up a silverlight application.

In this blog post we are going to serve a static html file from blob storage, but first we are going to upload it.  I created a very simple windows application to upload the file to the blob storage account I created in Azure.  I am assuming that you have already created a storage account.

The code above is a pretty standard use of the api that wraps around the rest service interface.  However I did notice quite a nice way of instantiating access to your account without the overhead of the configuration normally required when you start with a web role template project within Azure.

This involves creating a StorageCredentialsAccountAndKey object that takes name of the account and its key that you created within the Azure framework.  True this method is never going to be flexible enough to be acceptable in an enterprise scenario but for quick proof of concept or a small application designed to get you up to speed this is a nice way to get stuff up to Azure without having to write code to handle writing and reading to a configuration file.

Notice also in the code that we use to create the container

We make sure that the name of the container is specified in lower case.  Once the file is uploaded we can access it through the URL which in my case was

https://harkatcomputingtraining.blob.core.windows.net/mytestcontainer/7ef585ed-5ad0-439e-9dc0-d60b7fd204e9/HelloWorld.htm

Now I haven’t created a web role to host this page and if you look at our screenshot below

You can see we have reduced our monthly price considerably to $7.75 which is starting to put Azure in the same ball park as other hosting solutions.

Directory Structure and Content Delivery Networks

Of course web sites are structured hierarchically within folders, but you can simulate this by putting the slash within the blob name. Now we can significantly improve performance by using Content Delivery Networks (CDNs).  Basically a CDN is a method of delivering content by an optimised Edge server to as close to the requesting client as possible.  Content is uploaded to the originating server which then delivers to the edge server nearest to the request if the edge server has not already got a copy of the content.

A CDN edge server is located in the major data centers of

1) Los Angeles

2) Dublin

3) New York

4) London

5) Dubai

6) Hong Kong

7) Tokyo

Origin servers sole purpose is to serve content to the edge servers and it redirects requests to the nearest edge server.  If we click the CDN menu on the Azure portal under the storage account we can just enable a new CDN endpoint through the presented screen,

This will then give us a new endpoint as shown below

Now with a new endpoint comes a new address for accessing content as shown below and this has to be incorporated in the access url

Now this really isnt user friendly, but remember you can add you own domain name to make it more accessible, we wil cover this in a later blog post.

What we have achieved is a cheaper hosting solution in Azure for a certain type of site either web or silverlight.  It proves that with a bit of imagination that Azure can be a platform that viable to both hobbyists, very small companies and technology professionals.  The blob storage option gives us a cheap alternative to using some of the more expensive components of Azure such as compute instances and Sql Azure.