---
title: "Create Blob Service in Windows Azure"  
description: "Blob service is a storage area of windows azure where we can store our text and binary data."  
author: "Chris Anderson"  
published: 2012-01-23  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/865/create-blob-service-in-windows-azure  
category: "cloud computing"  
tags: ["cloud computing"]  
reading_time: 3 minutes  

---

# Create Blob Service in Windows Azure

Blob service is a storage area of windows azure where we can store our text and [binary data](https://www.mindstick.com/forum/161575/how-do-you-read-binary-data-from-a-file-in-c-sharp).\

The Blob service stores text and binary data. The Blob service offers the following resources: the storage account, [containers](https://www.mindstick.com/interview/2194/which-containers-use-a-flowlayout-as-their-default-layout-in-java), 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](https://www.mindstick.com/news/2675/bmw-agrees-to-integrate-blockchain-with-operations-partners-with-bnb-chain-coinweb) 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](https://yourviews.mindstick.com/view/81711/microsoft-disconnects-cortana-and-reinvents-it) [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010 as an administrator.

· To create a new project **File** – **New** – **Project**.

· 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](https://www.mindstick.com/mindstickarticle/672676f4-11c0-4dea-ab82-719c99ddcf2d/images/e7190439-38d2-4309-ae6b-f1374c07d519.png)

· To add an asp.net 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](https://www.mindstick.com/mindstickarticle/672676f4-11c0-4dea-ab82-719c99ddcf2d/images/56229066-41c8-42fd-b924-25da8b424e0d.png)

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");            blobContainer.CreateIfNotExist();             containerPermissions= new BlobContainerPermissions();            containerPermissions.PublicAccess= BlobContainerPublicAccessType.Blob;            blobContainer.SetPermissions(containerPermissions);            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](https://www.mindstick.com/articles/12909/how-to-open-first-time-popup-on-page-load-in-website) and also add a [xml file](https://www.mindstick.com/articles/75/how-to-read-and-write-xml-file-through-c-sharp) (Student.xml) from [local system](https://www.mindstick.com/forum/395/hosting-on-iis-on-local-system-in-windows-7) as content of blob (mycontainer).

Now press F5 to run [your application](https://answers.mindstick.com/qa/95487/how-do-you-troubleshoot-when-your-application-link-is-not-responding), The output should something like below if the file (**Student.xml**) was added successfully in a blob.

![Create Blob Service in Windows Azure](https://www.mindstick.com/mindstickarticle/672676f4-11c0-4dea-ab82-719c99ddcf2d/images/881b1d2b-c676-4e72-8a43-5edd2cad620d.png)

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](https://www.mindstick.com/mindstickarticle/672676f4-11c0-4dea-ab82-719c99ddcf2d/images/e7c32cab-884f-49a5-b809-c613b14beeff.png)

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

\

\

---

Original Source: https://www.mindstick.com/articles/865/create-blob-service-in-windows-azure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
