Azure 为什么会出现错误';提供的信息不映射到AD对象id;使用服务主体执行新AzRoleAssignment时?
在Azure DevOps管道中使用Powershell,我正在尝试将密钥保管库的主体角色Azure 为什么会出现错误';提供的信息不映射到AD对象id;使用服务主体执行新AzRoleAssignment时?,azure,powershell,azure-devops,azure-keyvault,azure-rbac,Azure,Powershell,Azure Devops,Azure Keyvault,Azure Rbac,在Azure DevOps管道中使用Powershell,我正在尝试将密钥保管库的主体角色存储帐户密钥操作员服务角色分配给存储帐户 命令行 命令行在我将Azure与服务主体连接后运行: $credentials = New-Object -TypeName System.Management.Automation.PSCredential($servicePrincipalApplicationId, $clientSecret) Connect-AzAccount -ServicePrinc
存储帐户密钥操作员服务角色
分配给存储帐户
命令行
命令行在我将Azure与服务主体连接后运行:
$credentials = New-Object -TypeName System.Management.Automation.PSCredential($servicePrincipalApplicationId, $clientSecret)
Connect-AzAccount -ServicePrincipal -Credential $credentials -Tenant $tenantId
以下是我执行的命令行:
New-AzRoleAssignment -ApplicationId $keyVaultServicePrincipalId -ResourceGroupName $resourceGroupName -ResourceName $storageAccountName -ResourceType "Microsoft.Storage/storageAccounts" -RoleDefinitionName "Storage Account Key Operator Service Role"
其中:
是Vault的密钥。其值为$KeyVault服务Principalid
cfa8b339-82a2-471a-a3c9-0fc0be7a4093
是存储所在的资源组的名称。其值为$resourceGroupName
accountsmanager test global rg
是我的存储帐户的名称。其值为$storageAccountName
accountsmanagertest
New-AzRoleAssignment: The provided information does not map to an AD object id.
为什么我会得到错误
提供的信息没有映射到AD对象id。
当执行命令New azroleasignment
时?我也可以在我这方面重现这一点,有两个问题
1.在您的命令中,ResourceType
应该是Microsoft.Storage/storageAccounts
,而不是Microsoft.Storage/storageAccount
2.在与DevOps servcie连接中使用的服务主体相关的广告应用程序的API权限中,您需要在Azure Active Directory Graph
中添加应用程序权限目录.Read.All
,而不是Microsoft Graph
一段时间后生效,它会很好地工作
我一直在避免使用遗留权限,但它可以正常工作。很好的回答:)