【问题标题】:Rerunning ARM template cause error重新运行 ARM 模板导致错误
【发布时间】:2018-02-28 02:43:14
【问题描述】:

我有一个非常简单的 ARM 模板,它启动了一个应用服务计划和一个网站。当我删除计划或资源组时,它可以正常工作并创建新的计划和网站。以下是模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "environment": {
      "type": "string",
      "metadata": {
        "comments": "The environment to suffix to distinguish resources in different groups"
      }
      "allowedValues": ["Test","Uat","Stage"]
    }, 
    "planName": {
      "type": "string"
    },
 /*Other Parameters*/
    }
  },
  "variables": {
    "planNameFull": /*expression*/,
    "siteTestNameFull": /*expression*/,
    "appDomainName": /*expression*/    
  },
  "resources": [
    {
      "comments": "Application Plan (Serverfarm)",
      "type": "Microsoft.Web/serverfarms",
      "sku": {
        "name": "S1",
        "tier": "Standard",
        "Size": "S1",
        "family": "S",
        "capacity": "1"
      },
      "kind": "app",
      "name": "[variables('planNameFull')]",
      "apiVersion": "2016-09-01",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
        "displayName": "[variables('planNameFull')]"
      },
      "properties": {
        "name": "[variables('planNameFull')]",
        "workerTierName": null,
        "adminSiteName": null,
        "hostingEnvironmentProfile": null,
        "perSiteScaling": false,
        "reserved": false,
        "targetWorkerCount": 0,
        "targetWorkerSizeId": 0
      }
    },
    {
      "comments": "Test Web Site",
      "type": "Microsoft.Web/sites",
      "kind": "app",
      "name": "[variables('siteTestNameFull')]",
      "apiVersion": "2016-08-01",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
        "displayName": "[variables('siteTestNameFull')]"
      },
      "properties": {
        "clientAffinityEnabled": true,
        "enabled": true,
        "hostNameSslStates": [
          {
            "name:": "[concat(variables('siteTestNameFull') ,'.azurewebsites.net')]",
            "sslState": "Disabled",
            "hostType": "Standard"
          },
          {
            "name:": "[concat(variables('siteTestNameFull') ,'scm.azurewebsites.net')]",
            "sslState": "Disabled",
            "hostType": "Repository"
          }
        ],
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms',variables('planNameFull'))]"
      },
      "dependsOn": [ "[resourceId('Microsoft.Web/serverfarms',variables('planNameFull'))]" ],
      "resources": [
        {
          "comments": "Test Web Site Config.",
          "type": "Microsoft.Web/sites/config",
          "name": "[concat(variables('siteTestNameFull'),'/web')]",
          "apiVersion": "2015-08-01",
          "tags": {
            "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
            "description": "[concat('Moula ', variables('siteTestNameFull'),' Settings')]",
            "displayName": "[concat(variables('siteTestNameFull'),' App Settings')]"
          },
          "properties": {
            "numberOfWorkers": 1,
            "defaultDocuments": [ "index.html" ],
            "netFrameworkVersion": "v4.7",
            "publishingUsername": "[parameters('webPublishingUser')]",
            "publishingPassword": "[parameters('webPublishingPwd')]",
            "siteAuthSettings": { "isAadAutoProvisioned": false },
            "ipSecurityRestrictions": [
              {
                "ipAddress": "115.xx.xxx.27",
                "subnetMask": null
              },
              {
                "ipAddress": "34.xxx.xx.90",
                "subnetMask": null
              }
            ],
            "appSettings": {
              "WEBSITE_TIME_ZONE": "[parameters('websiteTimezone')]",
              "WEBSITE_LOAD_CERTIFICATES": "[parameters('testCertificate')]"
            },
            "use32BitWorkerProcess": false,
            "managedPipelineMode": "Integrated",
            "virtualApplications": [
              {
                "virtualPath": "/",
                "physicalPath": "site\\wwwroot",
                "preloadEnabled": false,
                "vitualDirectories": null
              }
            ],
            "loadBalancingRules": [ "LeastRequests" ]
          },
          "dependsOn": [ "[resourceId('Microsoft.Web/sites',variables('siteTestNameFull'))]" ]
        }
      ]
    }
  ],
  "outputs": {
    "planId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Web/serverfarms', variables('planNameFull'))]"
    },
    "TestAppId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Web/sites',variables('siteTestNameFull'))]"
    }
  }
}

我的问题是我想将此模板作为 VSTS 构建管道步骤运行。当我尝试再次运行模板而不进行任何更改时,总是会导致以下错误:

Template deployment returned the following errors:
1:09:17 PM - Resource Microsoft.Web/sites 'TestWebsite' failed with message '{
  "error": {
    "code": "InternalServerError",
    "message": "There was an unexpected InternalServerError.  Please try again later.  x-ms-correlation-request-id: 8cd06d54-vvvv-wwww-xxxx-5e55029fc640"
  }
}'

我做错了什么?

【问题讨论】:

  • 在使用 VSTS 部署 ARM 模板时,您是否一直遇到同样的错误?
  • @juvchan 是的,相关 id 发生了变化,但对于我尝试的所有 3-4 个模板,最终结果都是一样的。其他模板更复杂(站点/配置/自定义域等)。所以我尝试了这个相对简单的。
  • 你能分享真正的错误吗?您可以使用 Azure 监视器获取它
  • 这是监视器所说的:af5ca351-e3f6-400c-9a09-cbb005afd9b2 | Microsoft.Resources/deployments/write | Failed | Error | 2018-02-28T02:37:20.3176865Z
  • @RuslanY 我将尝试删除 hostNameSslStates 部分。

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


【解决方案1】:

此类错误有多种原因。 This is the official documenation.

  • 您要部署到的任一服务在您要部署到的区域中发生停机。
  • Azure DevOps 本身的停机时间。
  • 您尝试部署的资源类型在该地区尚不可用。

【讨论】:

  • 在我的工作中,我引用了一个现有的 Azure 容器注册表,但 ARM 模板定义了在挪威东部,ACR 尚不可用,因此我不得不修改模板以添加另一个参数 acrLocation .
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-12-18
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
  • 2021-11-21
  • 2013-11-03
  • 1970-01-01
相关资源
最近更新 更多