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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With