I am unable to perform the Azure Powershell command Add-AzureKeyVaultManagedStorageAccount
, even though I am executing it under the subscription owner profile. I successfully create keyvault, storage account, and storage account key in the following manner:
$KeyVault = New-AzureRmKeyVault `
-VaultName "<redacted>" `
-ResourceGroupName $ResourceGroup.ResourceGroupName `
-Location $Location `
-EnabledForDiskEncryption `
-EnabledForDeployment `
-Tag $Tags
$StorageAccount = New-AzureRmStorageAccount `
-ResourceGroupName $ResourceGroup.ResourceGroupName `
-Name "<redacted>" `
-SkuName Standard_LRS `
-Location $Location `
-Kind "Storage" `
-EnableEncryptionService "Blob,File" `
-Tag $Tags `
-AssignIdentity
$StorageAccountKey = New-AzureRmStorageAccountKey `
-ResourceGroupName $ResourceGroup.ResourceGroupName `
-Name $StorageAccount.StorageAccountName `
-KeyName "key1"
but trying to manage the storage account key in my key vault fails
$KeyVaultManagedStorageAccount = Add-AzureKeyVaultManagedStorageAccount `
-VaultName $KeyVault.VaultName `
-AccountName $StorageAccount.StorageAccountName `
-AccountResourceId $StorageAccount.Id `
-ActiveKeyName "key1" `
-Tag $Tags
This is the error. As I mentioned, I am executing under the subscription owner profile, so how can it not have authorization? Secondly, the "same redacted object Id" identified below does not correspond to any object in my subscription that I can find. I first experienced this problem with Azure Powershell 4.2.1, and have since upgraded to 4.3.0 and still have the problem.
Add-AzureKeyVaultManagedStorageAccount : The client '<same redacted object Id>' with object id '<same redacted object Id>' does not have authorization to perform action
'Microsoft.Authorization/permissions/read' over scope
'/subscriptions/<subscription ID>/resourceGroups/<resource group name>/providers/Microsoft.Storage/storageAccounts/<storage account name>/providers/Microsoft.Authorization'.
At E:\BitSync\Scripts\Azure\Create-Environment.ps1:129 char:34
+ ... VaultManagedStorageAccount = Add-AzureKeyVaultManagedStorageAccount `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureKeyVaultManagedStorageAccount], KeyVaultErrorException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultManagedStorageAccount
BTW, there does not appear to be any way to manage Storage Account keys through Key Vault in the portal other than cut and paste.