Skip to content

Minimal windows azure blob storage sample.

December 28, 2011

I always loved hello world samples. These sample gives user first hands on,  into new language . It is more than a month since I have started exploring windows azure. I have gone through many books and articles. I could not find very simple hello world blob sample to get started quickly. So I decided to write one as follows.

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

static void Main(string[] args)
        {
            CloudStorageAccount csa = CloudStorageAccount.Parse(“UseDevelopmentStorage=true”);
             CloudBlobClient cloudBlobClient =  cloudStorageAccount.CreateCloudBlobClient();

            foreach (CloudBlobContainer con in cloudBlobClient.ListContainers())
            {
                Console.WriteLine(” container name is ” + con.Name);
            }
            Console.ReadKey();
        }

This sample uses StorageClient API to list the blob container in the development storage. Below are steps to create the program

1) Create simple console application in visual studio

2) add references to StorageClient assembly.

3) First line of code calls CloudStorageAccount.Parse function, which parse a connection string and returns a CloudStorageAccount created from the connection string. In this case it create the account object for developement storage.

4) Then in next line we create the CloudBlobClient object from the account.

5) It uses cloudBlobClient‘s ListContainers method to list the storage containers.

That’s it, hope you will like this…

Advertisements

From → Tech

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: