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

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


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


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.