Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the Azure Storage BlobClient and BlockBlobClient in v12 .NET SDK?

I've looked around but can't seem to find anywhere in docs and the Intellisense documentation for these APIs is nearly identical.

What is the difference between an Azure Storage BlockBlobClient and a BlobClient in the Azure Storage v12 SDK?

Which one should I be using for efficiently uploading file streams to Azure Blob Storage using the Azure Storage v12 .NET SDK?

Is there any difference between these two bits of code and how they get files up to the cloud??

var container = _blobServiceClient.GetBlobContainerClient(containerName);

var blobClient = container.GetBlobClient(filename); // this?
var blockBlockClient = container.GetBlockBlobClient(filename); // or this?
like image 875
Thiago Silva Avatar asked Feb 04 '26 06:02

Thiago Silva


2 Answers

Azure Blob Storage supports three kinds of blobs - Block, Page and Append. While a lot of operations are common for all of these blobs (like delete, copy, lease etc.), there are some operations which are specific to a blob type (like put block, put block list for block blobs). To see operations specific to a particular blob type, please see this: https://learn.microsoft.com/en-us/rest/api/storageservices/operations-on-blobs.

BlobClient provides functionality which can be used for all kinds of blobs.

However to deal with functionality only available with specific kind of blob, you will need to use a client specific for that e.g. BlockBlobClient to deal with block blobs, AppendBlobClient to deal with append blobs and PageBlobClient to deal with page blobs.

like image 77
Gaurav Mantri Avatar answered Feb 05 '26 22:02

Gaurav Mantri


BlockBlobClient is a specialization - when you know you're dealing with only block blobs, you can use this. It will have some special functions which will only apply for block blobs. More functionality.

BlobClient is a generic implementation - all its functions can be safely executed on any blob type - block/append/page. Less functionality.

In your case you can use either. They both have the functions you will need.

like image 39
Abhinav Pandey Avatar answered Feb 05 '26 22:02

Abhinav Pandey