2016-11-12 17 views
1

我想将资源中的某些值转换为变量。主机名具体。Azure RM模板将复杂值存入变量

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'))]" 
     ] 
     } 

什么将这些值(主机名)进入变量的正确方法?

回答

3

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

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