Create Blob Service in Windows Azure

Blob service is a storage area of windows azure where we can store our text and binary data.

The Blob service stores text and binary data. The Blob service offers the following resources: the storage account, containers, and blobs. Within your storage account, containers provide a way to organize sets of blobs.

You can store text and binary data in either of two types of blobs:

·         Block blobs, which are optimized for streaming.

·         Page blobs, which are optimized for random read/write operations and which provide the ability to write to a range of bytes in a blob.

Now I am going to explain how to create blob service and how to add content in a blob in a windows azure application.

·         Open Microsoft Visual Studio 2010 as an administrator.

·         To create a new project FileNewProject.

·         Select Cloud template from the Installed Templates.

·         Select Windows Azure Project and enter the name of the project as BlobService.

·         Click OK to proceed.

Create Blob Service in Windows Azure

·         To add an web role to the solution, choose ASP.NET Web Role and then choose the right arrow. The roles are displayed in the Windows Azure solution pane of the dialog box. You can rename it as QueueService.

·         Click OK to add.

Create Blob Service in Windows Azure

Now in order to add the Blob and its content in windows azure application, add the following code:

 protected void Page_Load(object sender, EventArgs e)


            CloudStorageAccount cloudStorageAccount;

            CloudBlobClient blobClient;

            CloudBlobContainer blobContainer;

            BlobContainerPermissions containerPermissions;

            CloudBlob blob;


            cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;

            blobClient = cloudStorageAccount.CreateCloudBlobClient();

            blobContainer = blobClient.GetContainerReference("mycontainer");



            containerPermissions = new BlobContainerPermissions();

            containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;


            blob = blobContainer.GetBlobReference("Student.xml");


            // File from local storage.

            blob.UploadFile(@"D:\rohit\xml file\Student.xml");

            Response.Write("File Uploadded successfully");




The above code add a mycontainer named blob in azure storage area on page load and also add a xml file (Student.xml) from local system as content of blob (mycontainer).

Now press F5 to run your application, The output should something like below if the file (Student.xml) was added successfully in a blob.

Create Blob Service in Windows Azure

Now in order to watch the content of a blob, open Blobs section present in the Server Explorer
(Ctrl + W + L) and expand the Development section in Windows Azure Storage and also expand Blobs section, now double click on the blob (mycontainer). It will display all the content present in the blob at right side of the window.

Create Blob Service in Windows Azure

I think after reading this article you can easily create blob service and store data in a blob in a windows azure application.

Leave Comment