簡體   English   中英

Azure ARM模板中資源上屬性的多個值

[英]Multiple values for a property on resource in Azure ARM Template

根據https://docs.microsoft.com/zh-CN/azure/azure-resource-manager/resource-group-create-multiple#property-iteration ,應該可以使用副本在資源上創建多個值,但我無法使其工作。 這是我的代碼...

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": { 
    "appServiceName": {
      "type": "string",
      "metadata": {
        "description": "Name of app service to apply SSL to."
      }
    },
    "certificateName": {
      "type": "string",
      "metadata": {
        "description": "User friendly certificate resource name"
      }
    },
    "appServicePlan": {
      "type": "string",
      "metadata": {
        "description": "App Service Plan Name"
      }
    },
    "keyVaultId": {
      "type": "string",
      "metadata": {
        "description": "Existing Key Vault resource Id with an access     policy to allow Microsoft.Web RP to read Key Vault secrets (Checkout README.md for more information)"
      }
    },
    "hostname": {
      "type": "array",
      "metadata": {
        "description": "Custom hostname for creating SSL binding. This hostname should already be assigned to the Web App"
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2017-03-30",
      "type": "Microsoft.Web/sites",
      "name": "[parameters('appServiceName')]",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/certificates', parameters('certificateName'))]"
      ],
      "properties": {
        "copy": [
          {
            "name": "hostnames",
            "count": "[length(parameters('hostname'))]",
            "input": {
              "name": "[copyIndex('hostnames')]",
              "properties": {
                "hostNameSslStates": [
                  {
                    "name": "[[copyIndex(hostname)]]",
                    "sslState": "SniEnabled",
                    "thumbprint": "[reference(resourceId('Microsoft.Web/certificates', parameters('certificateName'))).Thumbprint]",
                   "toUpdate": true
                  }
                ]
              }
            }
           } 
        ]
      }
    },
    {
      "type": "Microsoft.Web/certificates",
      "name": "[parameters('certificateName')]",
      "apiVersion": "2016-03-01",
      "location": "[resourceGroup().location]",
      "properties": {
        "keyVaultId": "[parameters('keyVaultId')]",
        "keyVaultSecretName": "[parameters('certificateName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms',parameters('appServicePlan'))]"
      }
    }
  ]
}

並返回錯誤:Code = InvalidTemplate; 消息=部署模板語言表達式評估失敗:“無法解析語言表達式'copyIndex(hostname)]':期望標記'LeftParenthesis'和實際的'RightParenthesis'。”。 有關用法的詳細信息,請參見https://aka.ms/arm-template-expressi

有什么想法我做錯了嗎?

提前致謝!

錯誤給出了:

"[[copyIndex(hostname)]]",更改為"[copyIndex('hostname')]"

您甚至在其他地方都擁有它,為什么不在這里?

並且您可能想這樣做:

"[parameters('hostname')[copyIndex('hostname')]]"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM