Azure RM模板将复杂值放入变量中

时间:2016-11-12 19:42:57

标签: azure azure-resource-manager

我想将一些资源从资源转移到变量中。主机名具体。

enter image description here 但是,官方文档中的语法似乎不起作用。 https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/#variables

      "variables": {
    "sites_site1_hostNames": {
      "hostNames": [
        "host1.com",
        "host2.com",
        "host3.net",
        "host4.azurewebsites.net"
      ]
    },
  },
    "resources": [
      {
        "type": "Microsoft.Web/sites",
        "name": "[variables('sites_site1_name')]",
        "apiVersion": "2015-08-01",
        "location": "West US 2",
       },
        "properties": {
          "name": "[variables('sites_site1_name')]",
          "hostNames": "[variables('sites_site1_hostNames')]",
          "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverfarm1'))]"
        },
        "resources": [],
        "dependsOn": [
          "[resourceId('Microsoft.Web/serverfarms', variables('serverfarm1'))]"
        ]
      }

将这些值(hostNames)移动到变量中的正确方法是什么?

1 个答案:

答案 0 :(得分:3)

像这样修改变量声明(添加"type": "array",):

"sites_site1_hostNames": {
  "type": "array",
  "hostNames": [
    "host1.com",
    "host2.com",
    "host3.net",
    "host4.azurewebsites.net"
  ]