azure - 部署包含 key 保管库中存储的证书的 ARM 模板时出错

标签 azure azure-resource-manager azure-keyvault

我正在尝试从发布管理部署 ARM 模板,其中包含“Microsoft.Web/certificates”资源,该资源引用存储在 key 保管库中的证书。当 key 保管库与我要部署到的资源组存在于同一订阅中时,此方法可以正常工作。但是,当 key 保管库存在于不同的订阅中时,我收到以下错误。

资源 Microsoft.Web/certificates“证书名称”失败并显示消息

{
    "Code": "BadRequest",
    "Message": "The parameter Properties.KeyVaultId has an invalid value.",
    "Target": null,
    "Details": [
    {
      "Message": "The parameter Properties.KeyVaultId has an invalid value."
    },
    {
      "Code": "BadRequest"
    },
    { 
      "ErrorEntity": {
        "Code": "BadRequest",
        "Message": "The parameter Properties.KeyVaultId has an invalid value.",
        "ExtendedCode": "51008",
        "MessageTemplate": "The parameter {0} has an invalid value.",
        "Parameters": [
          "Properties.KeyVaultId"
        ],
        "InnerErrors": null
      }
    }
    ], 
    "Innererror": null
}'

证书资源在我的模板中定义如下。

    {
        "type":"Microsoft.Web/certificates",
        "name": "SomeName",
        "location": "East US 2",
        "apiVersion": "2016-03-01",
        "properties": {
            "keyVaultId": "/subscriptions/<subscriptionId>/resourceGroups/<vault resource group>/providers/Microsoft.KeyVault/vaults/<vault name>",
            "keyVaultSecretName": "SecretName"                
        }            
    }

我正在 VSTS 中使用 Azure 资源组部署任务来部署资源组。该任务配置为使用具有服务主体的终结点,该服务主体在 Azure 中设置了以下权限:

  • 包含 key 保管库的资源组上的 key 保管库参与者角色。
  • 获取 key 保管库的 secret 权限

Microsoft.Azure.WebSites 主体被授予对 key 保管库 secret 的获取权限。

key 保管库还启用了“启用对 Azure 资源管理器的访问以进行模板部署”选项。证书是使用 powershell 上传到 key 保管库的,而不是通过门户。

我在这里遗漏了什么吗?

谢谢

最佳答案

我想我找到了这个问题的原因。显然,当资源组创建后,您就无法更改 secret 名称。如果这样做,将会抛出上面的错误。

如果您想更改 secret 名称,您需要删除资源组并重新部署所有内容。

您是否在 ARM 模板中更改了 secret 名称,而没有删除 Azure 门户中的完整资源组?

关于azure - 部署包含 key 保管库中存储的证书的 ARM 模板时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40879685/

相关文章:

azure-keyvault - Azure key 保管库 : Getting forbidden error if user is having direct access via Group to Key Vault

mysql - 即使 JOIN 表中不存在行也能获取结果

azure - 如何在运行时更新已部署的 ARM 模板的配置?

Windows Azure 虚拟机在扩展时访问网络速度很慢

powershell - 跨多个订阅列出自动化帐户中的所有 Azure Runbook

Azure PS 查询获取特定于给定资源组注册的资源提供程序

Azure Key Vault - 添加部署槽的访问策略

azure-keyvault - 如何在 Azure Key Vault 中存储公共(public)证书(.cer 文件)

authentication - 使用 REST 通过 ACS 对 Microsoft 帐户用户进行身份验证

c# - Azure函数: StatusCode cannot be set because the response has already started