代码之家  ›  专栏  ›  技术社区  ›  Gregory Suvalian

如何在链接模板中使用Azure Key Vault secret

  •  0
  • Gregory Suvalian  · 技术社区  · 8 年前

    我正在尝试根据KeyVault secret创建自动化变量。我假设我可以做与当前在主模板中检索windows密码相同的事情,但由于下面的非描述性错误而失败。不确定下一步应如何进行故障排除。

    错误

    {
      "code": "BadRequest",
      "message": "{\"Message\":\"The request is invalid.\",\"ModelState\":{\"variable.properties.value\":[\"An error has occurred.\"]}}"
    }
    

    样板

    {
                      "name": "mystring",
                      "type": "variables",
                      "apiVersion": "2015-10-31",
                      "dependsOn": [
                        "[concat('Microsoft.Automation/automationAccounts/', parameters('AutomationAccountName'))]"
                      ],
                      "properties": {
                        "value": {
                          "reference": {
                            "keyVault": {
                              "id": "[resourceId(subscription().subscriptionId, 'Utility-RG', 'Microsoft.KeyVault/vaults', 'MyKeyVault')]"
                            },
                            "secretName": "WindowsPasswordSecret"
                          }
                        },
                        "description": "test var",
                        "isEncrypted": false
                      }
                    }
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   4c74356b41    8 年前

    这个错误确实很有用,虽然我不知道哪里出了问题,但我可以告诉您如何解决这个问题,您需要将数据从KV传递到模板(作为输入参数),而不是传递到资源。在模板中,使用参数为相关对象赋值。

    参考号: https://github.com/4c74356b41/bbbb-is-the-word/blob/master/_arm/parent.json#L151