Nadar
Nadar

Reputation: 1992

Azure BlobClient VS CloudBlobClient

I've been learning Azure recently and I see that there are 2 classes for working with blobs: CloudBlobClient and BlobClient.

CloudBlobClient is fromMicrosoft.Azure.Storage.Blob; namespace, while BlobClient is from Azure.Storage.Blobsnamespace.

What is the difference between them? When would you use one over the other?

Upvotes: 20

Views: 11894

Answers (3)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30035

The package Azure.Storage.Blobs is latest version for azure blob storage, and Microsoft.Azure.Storage.Blob is the older version.

So we suggest that you should always use the BlobClient which is from the latest package. But if you have some old project which is using the old package, then in that case, you can use CloudBlobClient.

Porting guide: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/AzureStorageNetMigrationV12.md

Upvotes: 19

CyrilDex
CyrilDex

Reputation: 177

As already mentioned, Microsoft.Azure.Storage.Blob is the older SDK version 11, while Azure.Storage.Blobs starts from SDK version 12.

A critical difference is that the new SDK does not allow setting of permissions.

However, creating an instance of say BlobServiceClient does not require the creation of an intermediate CloudStorageAccount object, as the CloudBlobClient does. Simply supplying the connection string to the constructor of BlobServiceClient is enough to create this object.

Upvotes: 0

Koji
Koji

Reputation: 608

Azure.Storage.Blobs is a new version of Nuget package for Azure Blob Storage service. Microsoft.Azure.Storage.Blob is an older version.

Some classes including CloudBlobClient have been renamed in the new version. CloudBlobClient is renamed to BlobServiceClient.

The following page shows a list of renamed classes and sample code for upgrading to the new version.
https://elcamino.cloud/articles/2020-03-30-azure-storage-blobs-net-sdk-v12-upgrade-guide-and-tips.html

Upvotes: 7

Related Questions