例如,如果您想使用 Azure 自动化帐户运行 runbook 命令
Get-AzureKeyVaultSecret
,我们应该授予该 SP 权限,例如:
Microsoft Authorization
:
:
Microsoft Automation
Microsoft.Automation/automationAccounts/runbooks/read
Microsoft.KeyVault
需要这些权限:
Microsoft.KeyVault/vaults/read
Microsoft.KeyVault/vaults/secrets/read
Microsoft.KeyVault/vaults/accessPolicies/write
通常,我们可以为每个提供者设置角色。例如Microsoft.KeyVault
,我们希望 SP 可以更新密钥库或读取机密,我们可以添加Microsoft.KeyVault/vaults/write
andMicrosoft.KeyVault/vaults/secrets/read
和Microsoft.KeyVault/vaults/read
。
PS C:\Users\jason> Get-AzureRmProviderOperation * | ?{ $_.ProviderNamespace -eq 'Microsoft Key Vault' } | select Operation, OperationName
Operation OperationName
--------- -------------
Microsoft.KeyVault/register/action Register Subscription
Microsoft.KeyVault/unregister/action Unregister Subscription
Microsoft.KeyVault/hsmPools/read View HSM pool
Microsoft.KeyVault/hsmPools/write Create or Update HSM pool
Microsoft.KeyVault/hsmPools/delete Delete HSM pool
Microsoft.KeyVault/hsmPools/joinVault/action Join KeyVault to HSM pool
Microsoft.KeyVault/checkNameAvailability/read Check Name Availability
Microsoft.KeyVault/vaults/read View Key Vault
Microsoft.KeyVault/vaults/write Update Key Vault
Microsoft.KeyVault/vaults/delete Delete Key Vault
Microsoft.KeyVault/vaults/deploy/action Use Vault for Azure Deployments
Microsoft.KeyVault/vaults/secrets/read View Secret Properties
Microsoft.KeyVault/vaults/secrets/write Update Secret
Microsoft.KeyVault/vaults/accessPolicies/write Update Access Policy
Microsoft.KeyVault/operations/read Available Key Vault Operations
Microsoft.KeyVault/deletedVaults/read View Soft Deleted Vaults
Microsoft.KeyVault/locations/operationResults/read Check Operation Result
Microsoft.KeyVault/locations/deletedVaults/read View Soft Deleted Key Vault
Microsoft.KeyVault/locations/deletedVaults/purge/action Purge Soft Deleted Key Vault
完成后,我们可以将此角色分配给您想要的SP Get-AzureKeyVaultSecret
。我们可以为一个 SP 分配多个角色。
注意:
每个服务主体都需要Microsoft Authorization
权限,否则此 SP 将无法登录 Azure。
通常情况下,Azure PowerShell 命令Get
需要读取权限,New
需要写入权限。set
Update
希望这可以帮助:)