简体   繁体   English

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

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

I am trying to download and decrypt a blob from azure blob storage using vault key just like this tutorial, except that the linked tutorial is outdated.我正在尝试使用保管库密钥从 azure blob 存储中下载和解密 blob,就像教程一样,除了链接的教程已过时。 I am using the latest Azure.Storage.Blobs Nuget Package and do not see any way to do this as there is no BlobRequestOptions or BlobEncryptionPolicy object or similar in the package as is seen in the tutorial. I am using the latest Azure.Storage.Blobs Nuget Package and do not see any way to do this as there is no BlobRequestOptions or BlobEncryptionPolicy object or similar in the package as is seen in the tutorial. Everything that I look up points me back to the linked tutorial that is again outdated.我查找的所有内容都指向我再次过时的链接教程。

Here is my current code:这是我当前的代码:

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

Somewhere in here I would like to pass in my key vault key resolver to decrypt the blob like in the tutorial.在这里的某个地方,我想传递我的密钥库密钥解析器来解密 blob,就像教程中一样。

Is there a way to do that?有没有办法做到这一点?

If not, what is the current best way to decrypt blobs using key vault?如果不是,那么当前使用密钥库解密 blob 的最佳方法是什么?

For now, in Azure.Storage.Blobs , you can use EncryptionScope in BlobClientOptions .目前,在Azure.Storage.Blobs中,您可以在BlobClientOptions中使用EncryptionScope

In Azure.Storage.Blobs , you can use EncryptionScope in BlobClientOptions .Azure.Storage.Blobs中,您可以在BlobClientOptions中使用EncryptionScope You could refer to this article to create encryption scope.您可以参考这篇文章来创建加密 scope。 But the feature is in preview.但该功能处于预览阶段。

After configure azure storage container, you can upload blob with the specify encryption scope you created before and add the BlobClientOptions into BlobServiceClient .配置 azure 存储容器后,您可以使用之前创建的指定加密 scope 上传 Blob,并将BlobClientOptions添加到BlobServiceClient

在此处输入图像描述

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

You can use您可以使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM