使用版本 12.x Azure 存储库使用密钥保管库从 Azure blob 存储中解密 blob

Decrypt a blob from Azure blob storage with key vault using version 12.x Azure storage libraries

我正在尝试使用保管库密钥从 Azure Blob 存储下载和解密 Blob,就像 this 教程一样,只是链接的教程已过时。我正在使用最新的 Azure.Storage.Blobs Nuget 包,但看不到任何方法可以做到这一点,因为包中没有 BlobRequestOptionsBlobEncryptionPolicy 对象或类似的对象,如教程中所示。我查找的所有内容都让我回到了再次过时的链接教程。

这是我当前的代码:

BlobServiceClient serviceClient = new BlobServiceClient("connectionString");
BlobContainerClient containerClient = serviceClient.GetBlobContainerClient("containerName");
BlobClient blobClient = containerClient.GetBlobClient("blobName");
await blobClient.DownloadToAsync(myStream);

在这里的某个地方,我想传递我的密钥库密钥解析器来解密 blob,就像在教程中一样。

有办法吗?

如果不是,目前使用密钥保管库解密 blob 的最佳方法是什么?

目前,在 Azure.Storage.Blobs 中,您可以在 BlobClientOptions 中使用 EncryptionScope

Azure.Storage.Blobs中,您可以使用EncryptionScope in BlobClientOptions. You could refer to this article创建加密范围。但该功能处于预览状态。

配置 azure 存储容器后,您可以上传具有您之前创建的指定加密范围的 blob,并将 BlobClientOptions 添加到 BlobServiceClient

var options = new BlobClientOptions();
options.EncryptionScope= "joeyencrypt";
BlobServiceClient blobServiceClient = new BlobServiceClient("connectionString",options);

您可以使用

Azure.Storage.Blobs.Specialized.SpecializedBlobExtensions
        public static BlobClient WithClientSideEncryptionOptions(this BlobClient client, ClientSideEncryptionOptions clientSideEncryptionOptions);