Azure ARM 无法创建托管环境:'Location has an invalid value'

Azure ARM can't create hostingEnvironments : 'Location has an invalid value'

我无法在 ARM 模板中创建 "HostingEnvironments"。 我通常使用

"location": "[resourceGroup().location]"

但它似乎不适用于 "HostingEnvironments"

类型的资源
{
    "apiVersion": "2016-09-01",
    "name": "[variables('hostingEnvironment').name]",
    "type": "Microsoft.Web/hostingEnvironments",
    "location": "[resourceGroup().location]",
    "dependsOn": [
      "[concat('Microsoft.Network/virtualNetworks/', variables('vnet').name, '/subnets/', variables('vnet').subnet.name)]"
    ],
    "properties": {
      "Name": "[variables('hostingEnvironment').name]",
      "ipSslAddressCount": "[variables('hostingEnvironment').ipSslAddressCount]",
      "workerPools": [
        {
          "workerSizeId": 0,
          "workerSize": "medium",
          "workerCount": 1
        }
      ],
      "location": "[resourceGroup().location]",
      "MultiSize": "medium",
      "MultiRoleCount": "1",
      "VNETName": "[variables('vnet').name]",
      "VNetResourceGroupName": "[resourceGroup().name]",
      "VNETSubnetName": "[variables('vnet').subnet.name]"
    }
  }

这里是完整模板https://github.com/toto-castaldi/azure-templates/blob/master/serviceApp/template.json

如果我插入有线字符串 "West Europe" 将创建资源。

根据您的描述,我假设您正在通过 Azure ARM 模板部署带有应用服务环境的 WebApp。根据您的模板,我已经在我这边进行了测试,我可以重现这个问题。

我发现一位 issue about creating an App Service Environment, and as Stefan Schackow 是 Azure 网站的首席项目经理,他评论如下:

Just in case anyone runs into this - we uncovered a bug where the App Service management infrastructure isn't correctly handling the normalized location string returned from the resourceGroup.Location() call. For now, the workaround is as mentioned above - grab the March 21st version of the templates and explicitly provide a string for "location" in the azuredeploy.parameters.json file.

目前,解决方法是您需要在 azuredeploy.parameters.json 文件中为 "location" 明确提供一个字符串。我会报告这个问题,您也可以添加您的反馈 here