设置加密策略后未设置Azure Blob元数据属性EncryptionData [英] Azure blob metadata property EncryptionData is not set after setting encryption policy

查看:112
本文介绍了设置加密策略后未设置Azure Blob元数据属性EncryptionData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用密钥库中的秘密对blob进行加密.不幸的是,没有为Blob设置EncryptionData元数据属性.它以前曾在工作,但是由于某种原因,现在未设置该属性. 有人可以帮忙吗?请在下面找到我用于设置加密策略的代码.

I am encrypting a blob using secret from a keyvault. Unfortunately, the EncryptionData metadata propery is not being set for the blob. It was working previously, but for some reason the property is not being set now. Can anyone help please? Please find below the code i am using to set the encryption policy.

private void SetEncryptionPolicy(string containerName)
{
    IKey cloudKey1;

    var secret = string.Format(ConfigurationManager.AppSettings["SecretUri"], containerName);

    //// Create key instances corresponding to the key IDs. This will cache the secrets.
    try
    {
        cloudKey1 = _cloudResolver.ResolveKeyAsync(secret, CancellationToken.None).GetAwaiter().GetResult();
    }
    catch (AggregateException e)
    {
        _logger.Error("Azure KeyVault resolve key failed. Error: " + e.InnerException.Message);

        throw;
    }

    var encryptionPolicy = new BlobEncryptionPolicy(cloudKey1, _cloudResolver);

    _blobClient.DefaultRequestOptions.EncryptionPolicy = encryptionPolicy;
    _blobClient.DefaultRequestOptions.RequireEncryption = true;
}

推荐答案

您提供了一个非常不完整的代码示例,但是它似乎没有遵循所记录的模式.我将在这里查看示例代码.我可以保证它正常工作: https://azure.microsoft. com/en-us/documentation/articles/storage-encrypt-decrypt-blobs-key-vault/

You provided a very incomplete code sample but it doesn't seem to follow the documented pattern. I would review the example code here. I can vouch it works right: https://azure.microsoft.com/en-us/documentation/articles/storage-encrypt-decrypt-blobs-key-vault/

这篇关于设置加密策略后未设置Azure Blob元数据属性EncryptionData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆