从Azure容器解密并存储blob项

时间:2017-08-01 12:54:18

标签: c# azure azure-blob-storage

我想解密存储在容器中的blob项目,然后我想将该blob项目存储到本地计算机。

下面是我解密blob的代码

X509Store certStore = new X509Store();
string password = string.Empty;
X509Certificate2 certificate = 
FindCertificateByThumbprint
(@ConfigProvider.DecryptionCertificateFingerprint);
string containerName = @ConfigProvider.ContainerName;
CloudBlobContainer CsvContainer = GetAzureContainer(containerName);
var provider = new AsymmetricBlobCryptoProvider(certificate);
var decryptedMemoryStream = new MemoryStream();

foreach (IListBlobItem item in CsvContainer.ListBlobs(null, false))
{
    if (item.GetType() == typeof(CloudBlockBlob))
    {
        CloudBlockBlob blobItem = (CloudBlockBlob)item;
        CloudBlockBlob Csvblob = 
        CsvContainer.GetBlockBlobReference(blobItem.Name);
        Csvblob.DownloadToStreamEncrypted(provider, 
        decryptedMemoryStream);
    }
}

如何在本地计算机上下载这些解密的blob?

0 个答案:

没有答案