azure - 以编程方式创建 Azure KeyVault secret 时,如何修复“"Operation ' set' not allowed”错误?

标签 azure azure-keyvault

我正在尝试使用 Microsoft 以编程方式创建 Azure KeyVault secret 。 Azure.KeyVault.KeyVaultClient。出于我的目的,我将使用证书作为 Azure AD 应用程序进行身份验证 token 。 Azure AD 应用程序的 list 中已包含证书信息。

我的代码创建 Azure KeyVault,为 Azure AD 应用程序的对象 ID 的 secret 和 key 提供“所有”权限。我使用 Powershell 检索 KeyVault 并查看访问策略来验证是否发生了这种情况。

当我尝试使用 KeyVaultClient.SetSecretAsync() 在此 KeyVault 上创建 secret 时,出现异常,提示“不允许执行‘设置’操作。”状态代码为“禁止”。

除了在 KeyVault 上设置的权限之外,我是否需要确保对其他任何内容(例如 Azure AD 应用程序)的任何其他权限?

最佳答案

问题是访问策略不需要您的 Azure AD 应用程序的对象 ID。它实际上需要 Azure AD 应用程序的服务主体的对象 ID。

由于最近在portal.azure.com上添加了“应用程序注册”,我们可以轻松获取应用程序的对象ID。但是,Azure AD 应用程序的服务主体的对象 ID 无法通过 UI 获得(据我所知)。您可以通过 Powershell 获取它:

Get-AzureRmADServicePrincipal -ServicePrincipalName <app client ID>

关于azure - 以编程方式创建 Azure KeyVault secret 时,如何修复“"Operation ' set' not allowed”错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39901876/

相关文章:

node.js - Azure 计时器函数 - Microsoft.WindowsAzure.Storage : Settings must be of the form "name=value"

Azure 移动服务 PushNotifications 设备注册

azure - 如何检索生成的 Azure Key Vault 证书的 PFX 密码?

azure - 在不知情的情况下通过 ARM 将 secret 添加到 Vault

azure - 将 SSL 证书从 Azure key 保管库添加到现有 VM linux vm

.net - 带有 Azure Key Vault 的 PKI

azure - 如何在一次休息 API 调用中从 azure key Vault 获取最新的 secret 版本值

wcf - 将 SSL 与 WP7、WCF 服务和 Azure 结合使用

azure - 如何在 API-M 中记录 TLS 版本?

powershell - 在 Azure 上每小时运行一次 Powershell 脚本