v12 .NET SDK 中的 Azure Storage BlobClient 和 BlockBlobClient 有什么区别?

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

我环顾四周,但似乎无法在文档中找到任何地方,而且这些 API 的 Intellisense 文档几乎相同。

Azure 存储 BlockBlobClient 和 Azure 存储 v12 SDK 中的 BlobClient 有什么区别?

我应该使用哪个来使用 Azure Storage v12 .NET SDK 高效地将文件流上传到 Azure Blob Storage?

这两段代码以及它们如何将文件上传到云端有什么区别吗??

var container = _blobServiceClient.GetBlobContainerClient(containerName);

var blobClient = container.GetBlobClient(filename); // this?
var blockBlockClient = container.GetBlockBlobClient(filename); // or this?

Azure Blob 存储支持三种 blob - 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://docs.microsoft.com/en-us/rest/api/storageservices/operations-on-blobs

BlobClient 提供可用于各种 blob 的功能。

然而,要处理仅适用于特定类型 blob 的功能,您将需要使用特定的客户端,例如BlockBlobClient to deal with block blobs, AppendBlobClient to deal with append blobs and PageBlobClient 处理页面 blob。

BlockBlobClient 是一个专门化 - 当您知道您只处理块 blob 时,您可以使用它。它将具有一些仅适用于块 blob 的特殊功能。更多功能。

BlobClient 是一个通用实现 - 它的所有功能都可以在任何 blob 类型上安全地执行 - block/append/page。功能较少。

在您的情况下,您可以使用其中任何一种。它们都有您需要的功能。