Getting Started with Azure Blob and other Storage Service

Azure Blob is a cloud storage service from Azure, and great to master if your web service needs to store binary data and text.

  • Index
    • Understanding Structure of Blob Service
    • CRUD of Container
    • CRUD of Blob

The master document of how to is here;

What is Azure Blob storage?

Azure Blob storage is a service that stores file data in the cloud. Blob storage can store any type of text or binary data, such as a document, media file, or application installer. Blob storage is sometimes referred to as object storage.

OK. Azure Blob sounds like service for almost all web services.

What is Blob Storage

It is a service for storing large amounts of unstructured data, such as text or binary data, that can be accessed from anywhere in the world via HTTP or HTTPS. You can use Blob storage to expose data publicly to the world, or to store application data privately.

Common uses of Blob storage include:Serving images or documents directly to a browser.  Storing files for distributed access.  Streaming video and audio.  Performing secure backup and disaster recovery.  Storing data for analysis by an on-premises or Azure-hosted service

Great these are all thing I want to do.  Let’s see how we can use this service.

Understanding Structure of Blob Service.

Blob service consist of three layers.  Account  > Container > Blob

There are three types of blobs, block blobs, page blobs, and append blobs.

You can have unlimited containers in one account, and unlimited number of blobs in one container.  But there is limitation within blob, that is;

block blob, 50,000 blocks of up to 4 MB each, for a total size of slightly more than 195 GB (4 MB X 50,000).  Page blobs can be up to 1 TB in size, and are more efficient for frequent read/write operations.

OK,  time to code.  First, obtain all related SDK from Nuget.


Assuming you already have account. (if not please follow the master document and create one)  Let’s cover container first.

CRUD of Container

Get List of Containers

To get list of containers that belongs to your account, we simply call ListContainers from the blob client class.

I am storing credential information in Web.config like below;

And here is



There is no custom model involved in this. I just simply use model, Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.  After you execute, you should see web page like below.


I now see that I currently have two containers for this account.

Create Container

Now let’s take a look at how to create new container. Container is simple, it really is just a container and not much else.

Here, I am taking string variable name, then I m creating blob container class from blob client, then attempt to get reference to the container.  Then call CreateIfNotExist action.  I think this can be more friendly, like handling cases when specific container exist etc.. or validate name format, but I ll get to that later.



This is the view,


and great, now I see my 3rd container created with name I specified.


One of the main thing you can do with container is set access level.  You notice that Public Access is off by default.  Let’s see how we can make this publicly accessible container later.


Now that we have container covered, let’s look at blob part.

CRUD of blob

Get list of blob for specific container

You notice I created function to retrieve blob client, since I was repeatedly calling to create blob client.



Then you should see the whole list of blob under the container nvideospace like below.


Now, Let’s upload blob into the container.

Upload (Create) Blob

On first run, I was getting “404.13 Content Length Too Large” error.  If you are trying to upload large file like video file, you are likely to exceed default file size limit and get an error.  You ll need to go to your Web.config and set limit like below.

I have heard default is 4Mb, but anyhow I ll change it to 2147483647, which is max number allowed.  File size limitation is checked at application level and server level, so you will need to set both.  It wouldn’t make sense to have different limitation so I set both at 2147483647.  I want to dig more into file size and type of videos later to understand how these limitations should be set.



So the interface to upload blob looks like below.  A user needs select container where they want to upload blob to, and name of blob, then select file from local.  You will need to make sure you have specified enctype at form to multipart/form-data, in order to retrieve streaming file from the local machine of the user.  You can do so along with html attribute you pass at Html.BeginForm.

Here, I am getting a list of containers and dump them into ViewBag and map them on drop down list for a user to select.


After upload is complete, I redirect user to the list of blob for the specific container, and now you should see the file you just upload like below.スクリーンショット_013116_012026_PM

Serving Blob



I will update more on how you can make more friendly interfaces, and doing uploads at back-ends, connecting to Azure media services etc.

Leave a Reply