我使用带有证书的服务原则登录到azure powershell,如下所示:
Add-AzureRmAccount -ServicePrincipal -CertificateThumbprint $thumbprint -ApplicationId $applicationid -TenantId $tenant
然后我试着得到一个蔚蓝的秘密:
$b = Get-AzureKeyVaultSecret -VaultName $keyVaultName -Name 'AccountKey'
但是我得到一个错误:
不允许"get"
我想我给了读访问权限,像这样:
New-AzureRmRoleAssignment -RoleDefinitionName Reader -ServicePrincipalName $azureAdApplication.ApplicationId.Guid
有什么建议吗?
如果您没有正确的访问策略,请使用set - azurermkeyvaultaccessppolicy:
为serviceprinciple赋予get权限Set-AzureRmKeyVaultAccessPolicy -VaultName 'Contoso03Vault' -ServicePrincipalName 'http://payroll.contoso.com' -PermissionsToSecrets Get