问题描述
我在Azure DevOps管道中使用Powershell,我试图将密钥保险库的委托人的角色void*
分配给存储帐户。
命令行
将Azure与服务主体连接后,将运行命令行:
[[no_unique_address]]
这是我执行的命令行:
Storage Account Key Operator Service Role
位置:
-
$credentials = New-Object -TypeName System.Management.Automation.PSCredential($servicePrincipalApplicationId,$clientSecret) Connect-AzAccount -ServicePrincipal -Credential $credentials -Tenant $tenantId
是Key Vault的pre-registered principal ID。其值为New-AzRoleAssignment -ApplicationId $keyvaultServicePrincipalId -ResourceGroupName $resourceGroupName -ResourceName $storageAccountName -ResourceType "Microsoft.Storage/storageAccounts" -RoleDeFinitionName "Storage Account Key Operator Service Role"
。 -
$keyvaultServicePrincipalId
是存储所在的资源组的名称。其值为cfa8b339-82a2-471a-a3c9-0fc0be7a4093
。 -
$resourceGroupName
是我的存储帐户的名称。其值为accountsmanager-test-global-rg
。
服务主体
以下是运行该命令的服务主体的权限:
该命令作为在订阅中具有所有者角色的服务主体运行:
在该订阅中创建的资源组也归该服务主体所有:
问题
运行命令时,出现以下错误:
$storageAccountName
为什么在执行命令accountsmanagertest
时出现错误New-AzRoleAssignment: The provided @R_8_4045@ion does not map to an AD object id.
?