简体   繁体   English

如何在我的 Azure Data Lake Store 帐户上启用 AzureRmDataLakeStoreKeyVault?

[英]How to Enable-AzureRmDataLakeStoreKeyVault on my Azure Data Lake Store account?

I did the following things to create an Azure Data Lake Store account and then try to enable a key vault for it:我执行了以下操作来创建一个 Azure Data Lake Store 帐户,然后尝试为其启用密钥保管库:

New-AzDataLakeStoreAccount -ResourceGroupName TestRG -Name TestDLSA -Location "East US 2"
Enable-AzureRmDataLakeStoreKeyVault -Account TestDLSA

And received the following error:并收到以下错误:

Enable-AzureRmDataLakeStoreKeyVault : Operation EnableKeyVault is invalid under current encryption state or config of account.

What do I need to do to be able to correctly run Enable-AzureRmDataLakeStoreKeyVault on my Azure Data Lake Store account?我需要做什么才能在我的 Azure Data Lake Store 帐户上正确运行 Enable-AzureRmDataLakeStoreKeyVault?

When you creating the dls, you need to pass the parameters as below.创建 dls 时,需要传递如下参数。 Otherwise, it creates the dls with Service managed encryption , ie -Encryption ServiceManaged .否则,它会使用Service managed encryption创建 dls,即-Encryption ServiceManaged

New-AzDataLakeStoreAccount -ResourceGroupName <RG-name> -Name joydls -Location "East US 2" -Encryption UserManaged -KeyVaultId "<keyvault-resource-id>" -KeyName "testkey" -KeyVersion "444243d9xxxx8db2303d1"

To enable a user managed Key Vault for encryption, the service principal created automatically along with your dls needs the permission to access the key in your keyvault, so we need to configure the access policy for the service principal, run the command below after creating the dls, then it will work fine.要启用用户管理的 Key Vault 进行加密,与您的 dls 一起自动创建的服务主体需要访问您的 keyvault 中的密钥的权限,因此我们需要为服务主体配置访问策略,创建后运行以下命令dls,然后它将正常工作。

$ObjectId = (Get-AzDataLakeStoreAccount -ResourceGroupName <RG-name> -Name joydls).Identity.PrincipalId
Set-AzKeyVaultAccessPolicy -ResourceGroupName <RG-name> -VaultName joykeyvault -ObjectId $ObjectId -PermissionsToKeys encrypt,decrypt,get
Enable-AzDataLakeStoreKeyVault -Name "joydls"

在此处输入图像描述

Check in the portal:登录门户:

在此处输入图像描述


Besides , I notice you are using the new Az module mixed with the old AzureRm , please don't do this, sometimes it will cause an error, I recommend you to just use the Az module Enable-AzDataLakeStoreKeyVault , because the AzureRm module has been deprecated and will not be updated.此外,我注意到您正在使用新的Az模块和旧的AzureRm混合使用,请不要这样做,有时会导致错误,我建议您只使用Az模块Enable-AzDataLakeStoreKeyVault ,因为AzureRm模块已经已弃用,不会更新。

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

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