Get-AzureKeyVaultSecret:无法检索 ServicePrincipal 帐户的服务密钥

Get-AzureKeyVaultSecret : Unable to retrieve service key for ServicePrincipal account

我在 Azure 自动化 Runbook 中做 Get-AzureKeyVaultSecret。但是我收到以下错误。如何修复 Azure 自动化 Runbook 中的此错误?在哪里登录以及在哪里提供凭据?

Get-AzureKeyVaultSecret : Unable to retrieve service key for ServicePrincipal account xxxxxxxxxxxxxxxxxxx. Please log in again to supply the credentials for this service principal

如果您希望 Azure 自动化帐户的运行手册能够访问密钥保管库的机密,那么需要将 Azure 自动化 运行 作为帐户的应用程序 ID(即服务主体)添加到各自的密钥库。当您添加它时,请确保提供 'Get' 和 'List' 秘密权限。

要详细解释,请转到 Azure 门户 -> 自动化帐户 -> YOURAUTOMATIONACCOUNT -> 运行 作为帐户 -> Azure [= 获取 Azure 自动化 运行 作为帐户的应用程序 ID 27=] 作为帐户 -> 复制应用程序 ID。然后通过转到 Azure 门户 -> 密钥保管库 -> YOURKEYVAULT -> 访问策略 -> 单击 'Add new' -> Select 主体 -> 将获取的应用程序 ID 粘贴到搜索框 -> 单击 'Select' -> 单击 'Secret permissions' 下的下拉列表 -> 勾选 'Get' 和 'List' -> 单击 'OK'.

现在路由回您的 Azure 自动化帐户并启动您的 Runbook,然后您应该能够毫无问题地获取密钥保管库的机密。

希望对您有所帮助!!干杯!!