Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage Blobs: what kind of blob do I get with GetBlobReference()?

I'm getting a little confused with blobs. I've read some articles that says that there are two kinds of blobs, blocks and pages, but I can see in the SDK's library a third one:

container.GetBlockBlobReference(); // Block Blob, max 64Mb per block,  max 200Gb in total.
container.GetPageBlobReference(); // Page Blob, aligned to 512bytes pages,  max 1Tb in total.
container.GetBlobReference(); // ??

Is CloudBlob a CloudBlockBlob or a CloudPageBlock? Which constrains applies? Do I have to worry about file size and put blocks or pages when I use that reference?

I've been reading MSDN but I cannot find which one is.

like image 366
vtortola Avatar asked Feb 04 '11 00:02

vtortola


People also ask

How many types of blob storage are there?

The storage service offers three types of blobs, block blobs, append blobs, and page blobs.

What is the difference between block blob vs page blob?

The size of a single block blob is slightly higher than the normal, 4.75 TB, so the total size is 100 MB x 50,000 blocks. You can insert, delete, and replace blobs. Page Blobs: They are comprised of 512-byte pages that are optimized for arbitrary read and write operations.

Which type of blob is best suited for .VHD files?

Page blobs are used primarily as the backing storage for the VHDs used to provide durable disks for Azure Virtual Machines (Azure VMs). They are named page blobs because they provide random read/write access to 512-byte pages.


2 Answers

GetBlobReference returns you a CloudBlob object. That can represent either kind of blob. The .ToPageBlob and .ToBlockBlob properties will aid in casting the object, but that has nothing to do with the type of the blob that exists. The blob that exists is of one type or the other, specified when you create it.

If you call .Create on a CloudPageBlob object, that will result in a page blob being created in Windows Azure.

If you call .UploadText() on a BlockBlobObject (or a generic CloudBlob object), that will result in a block blob being created in Windows Azure.

In other words, GetBlobReference returns you a generic reference to a blob (not to either type).

like image 84
user94559 Avatar answered Nov 05 '22 23:11

user94559


It seems to always create a block blob on Azure when you use the generic CloudBlob object. However you are able to retrieve both block blobs and page blobs from storage using that class.

like image 28
Jeff Hornby Avatar answered Nov 05 '22 22:11

Jeff Hornby