Saturday, March 20, 2010

Windows Azure – BLOB Storage

What is BLOB ? –

Binary Large OBjects.

Windows Azure basically provides 4 type of storages

1) BLOB

2) Tables

3) Queues

image

4) Drive ( This is new) – NTFS drive.

In this Blog post i am going to use BLOB storage to store Binary Objects like  Images , Videos , etc..

Blobs can be used to store data that is unstructured. Windows Azure account holder  can create one or more containers to store related collections of blobs. Containers can be setup as either private or public. If a container is setup as public than any internet user will be able to read the blobs contained within it using the proper URL. If a container is marked as private than the secret key that comes with a Windows Azure storage account will be needed to access the blobs within the container. Additionally, if a single Blob is very large then Windows Azure provides tools to break up these large blobs into blocks so that they may be transferred to Windows Azure Blob storage more efficiently.

image  

image

Container Rules

  1. Container name must be a valid Domain Name System (DNS) name, conforming to the following naming rules.
  2. Must start with a letter or number, and can contain only letters, numbers, and the period (.) and dash(-) characters.
  3. All letters must be lowercase.
  4. Must be from 3 to 63 characters long.
  5. A name cannot contain a dash next to a period.

The following screenshot shows the Methods of my Windows Azure Service project .Now we are going to create these methods and we will be using in ASP.NET Web UI to Upload  the BLOB into Azure Storage. [Note: Here i am using my local Development Fabric ]

image

Here is the ASP.NET Web UI for this application.

 image

First Run VS.NET 2010 as an Administrator  and then create Cloud service project .

image

Now add ASP.NET Web Role to it. Open of Default.aspx Code behind file and  Create  CloudBlobClient private variable we will be using more often this.

InitBlobAccess:

This method Create a Local windows Azure Blob storage.

image

CreateContainer:

This method will create a container and set the access permission as public . [By default Windows Azure Blob storage permission is private. ]

image

DeleteContainer:

This method delete the container by given name.

image

ListBlobContainers:

This method  returns all publicly accessible[ permission] containers.

image

ListBlob:

This method returns a List of all available Blobs for selected (given) container in Dropdown List.

image

Upload File:

This method will enumerate all the uploaded file and load the content into Selected container and create the Blob in Windows Azure Blog Storage. 

image

Now wire up the above methods with ASP.NET WEB UI and upload the BLOB content and test it.

image

For more on Blob please visit http://blogs.msdn.com/windowsazure/archive/2009/11/25/windows-azure-storage-at-pdc-2009.aspx

Nandri(Thanks)

SreenivasaRagavan.

No comments: