【问题标题】:Error on deployment Azure Automation Variable Assets部署 Azure 自动化变量资产时出错
【发布时间】:2018-06-18 14:33:27
【问题描述】:

当我尝试将变量部署到 Azure 自动化资产时,出现错误,无法部署我的资源。

假设这个模板

{
   "name": "myVariable",
   "type": "Microsoft.Automation/automationAccounts/variables",
   "apiVersion": "2015-10-31",
   "dependsOn": [
      "[resourceId('Microsoft.Automation/automationAccounts', variables('automationAccountName'))]"
   ],
   "location": "[variables('automationLocation')]",
   "properties": {
      "isEncrypted": "false",
      "value": "8f703df8-0448-4ee3-8629-fc3f01840683"
    }
}

部署抛出异常:

{\"Message\":\"The request is invalid.\",\"ModelState\":{\"variable.properties.value\":[\"Invalid JSON primitive: a7d14fb0-232e-4fa0-a748-c7c8fb2082e2.\"]}}

我也尝试过:

"value": "\"8f703df8-0448-4ee3-8629-fc3f01840683\""

但是任何尝试都失败了!

有人知道如何使用 ARM 模板配置变量资产吗?

【问题讨论】:

    标签: azure azure-resource-manager azure-automation arm-template


    【解决方案1】:

    查看示例,您应该转义引号:

    {
      "name": "sampleVariable",
      "properties": {
        "value": "\"ComputerName.domain.com\"",
        "description": "my description",
        "isEncrypted": false
      }
    }
    

    Reference

    【讨论】:

      【解决方案2】:

      如果您尝试使用 ARM 变量或参数填充“值”键,则需要连接双引号。

      {
        "name": "myVariable",
        "type": "variables",
        "apiVersion": "2015-10-31",
        "properties": {
          "value": "[concat('\"', parameters('myVariableValue'), '\"')]"
         },
         "dependsOn": [
           "[resourceId('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
         ]
      }
      

      【讨论】:

        猜你喜欢
        • 2017-06-07
        • 1970-01-01
        • 2012-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多