Posts Tagged ‘Windows Azure 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”);

cloudContainer.CreateIfNotExist();

//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();

rnd.NextBytes(data);

//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.

pageBlob.FetchAttributes();

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.

pageBlob.Delete();

}

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);

}

Console.WriteLine(“>”);

}

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

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 BlockBlob is a solution based on the Blob Storage that mainly helps optimize the performance. The Blob storage is a perfect way to store data, from different kind, from PDFs, Docs, to PNG, JPEG or AVIs and others.

Now to optimize the transfer of the data Windows Azure Storage introduced the Windows Azure Block Blob that helps dividing the large blobs in smaller blocks to facilitate the transfer between the Windows Azure datacenter and the clients that are trying to access the data. One of the main problems that the BlockBlob helps avoid is that when sending a specified blob to the client, an error may occur when transferring these packets, one of these packets may face any kind of problem. Dropping any kind of these packets will require the transfer of the whole blob another time. However if you are using the Windows Azure BlockBlob, when sending a BlockBlob from the server to the Client, this blob is divided into small blocks if any of these faces any kind of problems the server will only transfer the block dropped.

BlockBlob let you upload a large block efficiently uploaded. The maximum size of a block is 4 MB maximum and the maximum size of the blob block is 200 GB. Each block has a block ID and the block is not committed until you give the all the blocks their IDs. With blob block you can upload multiple blocks parallel in the same time decreasing the time of uploading. You can upload the blocks in any order and define their sequence in the final block list.

You can also find an example for building an application using .Net and C# to start working with the Windows Azure BlockBlob. You can use something like the following code, where it represents another small brief introduction into the Windows Azure BlockBlob but using the Node JS.

var azure = require(‘azure’);

var blobservice= azure.createBlobService();

var options = {contentType: request.uploadedFile.Type };

blobservice.createContainerIfNotExists(request.containerName, function(error){

if(!error){

response.send(statusCodes.Ok, {message:’Container Created’});

}

});

blobservice.createBlockBlobFromFile(request.containerName,request.fileName, request.uploadedFile.path, options, function(error)

{if(!error){

response.send(statusCodes.OK, {message:’blockblob created’});

}

});

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

With the introduction of the Windows Azure Media Services, you might not need to use the Windows Azure BlockBlob especially that the Windows Azure Media Services mainly helps a lot in streaming the Media files. However if you are working with files with a large size of file, you will certainly have to think about using the Windows Azure BlockBlob.

We have seen before in previous blog posts how to communicate between the Windows Azure Cloud Services roles WebRole and WorkerRole using Queue Storage. I also introduced the Windows Azure Service Bus, and showed the development of the Windows Azure service bus using queue messaging. As both of these types of queue are used for the connection between multiple roles, like the previous explained WebRole and WorkerRole communication using the queue storage and the inter role communication using the Service Bus queues.

For the Queue storage, some people don’t consider it as a storage for a simple reason that it is not durable. The queue storage only be stored for a maximum time of 7 days as for the Windows Azure Service Bus queues, its time to live is more flexible than the queue storage and you can decide its duration on creating the Service Bus itself on Windows Azure. For the queue message, the queue storage will not allow more than 64 KB in the same time the service bus queue messaging will accept more than 64 KB it can work with more than that but less than 256 KB. In the other hand, this point that you should take in consideration that the Windows Azure Queue storage will give you the ability to exceed 5 GB as the total size of all queue messages in the interval of time to live but the service bus queue storage will not allow you to reach this size, it is preferable that the total size of all queues be less than 5 GB during the interval of time to live for the messages.

However the queue storage is a very easy to implement, you can see an example in the following link. For the Windows Azure Service Bus brokered messaging using queue storage, will require more development, integration with WCF service.

You can find all about the predefined functions for the queue storage in the following document. You can also find all the predefined functions for the Microsoft.ServiceBus DLL and the Microsoft.ServiceBus.Messaging DLL.

For more information about the differences I really recommend you to read the following web page.