Posts Tagged ‘Blob Storage’

Previously I have blogged about Windows Azure Blob Storage, getting here in more details about it. The Windows Azure Blob Storage is the unstructured data, where a lot of solutions and services is based on. The Windows Azure PageBlob is another type of the Blob Storage after introducing the Windows Azure BlockBlob.

The Windows Azure PageBlob is mainly used for the pages that requires a lot input and output. For example a static page that waits a lot of incoming users to complete the form. The PageBlob is mainly designed to meet all these requirements. The Maximum size of a PageBlob is 1 TB where each page blob is up to 4MB after the user finish the writing request in the page.

You can also find the following code example for building an application using .Net and C# to start working with the Windows Azure PageBlob.

static void WriteToPageBlob(Uri blobEndpoint, string accountName, string accountKey)


//Create service client for credentialed access to the Blob service.

CloudBlobClient blobClient =

new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

// create container if it does not exist

CloudBlobContainer cloudContainer = blobClient.GetContainerReference(“mypageblobs”);


//Get a reference to the page blob that will be created.

CloudPageBlob pageBlob = cloudContainer.GetPageBlobReference(“apageblob”);

//Generate some data to write.

byte[] data = new byte[1024];

Random rnd = new Random();


//Create a 100 MB page blob.

pageBlob.Create(100 * 1024 * 1024);

//Write two sets of pages. Note that you can write 4 MB per call to WritePages().

pageBlob.WritePages(new MemoryStream(data), 0);

pageBlob.WritePages(new MemoryStream(data), 4096);

//Populate the page blob’s attributes.


Console.WriteLine(“Blob length = {0}”, pageBlob.Properties.Length);

//Print out the current range of pages.

PrintPageRanges(“Before write to 10240:”, pageBlob);

//Write another page.

pageBlob.WritePages(new MemoryStream(data), 10240);

//Print out the new range of pages.

PrintPageRanges(“After write to 10240:”, pageBlob);

//Clear a page.

pageBlob.ClearPages(4096, 1024);

//Print out the new range of pages.

PrintPageRanges(“After clearing page at 4096:”, pageBlob);

//Delete the page blob.



static void PrintPageRanges(string msg, CloudPageBlob cloudBlob)


//Write out the page ranges for the page blob.

IEnumerable<PageRange> ranges = cloudBlob.GetPageRanges();

Console.Write(“{0}:<“, msg);

foreach (PageRange range in ranges)


Console.Write(” [{0}-{1}] “, range.StartOffset, range.EndOffset);




You can find another details about the other type of Windows Azure BlockBlob in this post.