包含Web应用程序配置设置的ARM模板

包含Web应用程序配置设置的ARM模板

问题描述:

部署ARM模板时遇到奇怪的行为.

I am encountering strange behavior when deploying an ARM template.

我有以下模板:(请注意,sasUrl值'xxx'在我的文件中具有实际的工作值)

I have the following template: (Note that sasUrl value 'xxx' has a real, working value in my file)

{
  "name": "[variables('webAppServiceName')]",
  "type": "Microsoft.Web/sites",
  "location": "[resourceGroup().location]",
  "apiVersion": "2016-08-01",
  "dependsOn": [
    "[concat('Microsoft.Web/serverfarms/', variables('appServicePlanName'))]"
  ],
  "tags": {
    "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]": "Resource",
    "displayName": "[variables('webAppServiceName')]"
  },
  "properties": {
    "name": "[variables('webAppServiceName')]",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  },
  "resources": [
    {
      "apiVersion": "2014-11-01",
      "name": "appsettings",
      "type": "config",
      "dependsOn": [
        "[concat('Microsoft.Web/sites/', variables('webAppServiceName'))]",
        "[concat('Microsoft.Web/certificates/', variables('certificateName'))]"
      ],
      "tags": {
        "displayName": "WebAppSettings"
      },
      "properties": {
        "WEBSITE_LOAD_CERTIFICATES": "[reference(resourceId('Microsoft.Web/certificates', variables('certificateName')), providers('Microsoft.Web', 'certificates').apiVersions[0]).thumbprint]"
      }
    },
    {
      "apiVersion": "2016-08-01",
      "name": "Microsoft.ApplicationInsights.Profiler.AzureWebApps",
      "type": "siteextensions",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppServiceName'))]"
      ],
      "properties": {}
    },
    {
      "apiVersion": "2015-08-01",
      "name": "logs",
      "type": "config",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppServiceName'))]"
      ],
      "properties": {
        "applicationLogs": {
          "fileSystem": {
            "level": "Off"
          },
          "azureTableStorage": {
            "level": "Off"
          },
          "azureBlobStorage": {
            "level": "[parameters('applicationLogLevel')]",
            "sasUrl": "xxx"
          }
        },
        "httpLogs": {
          "fileSystem": {
            "enabled": false
          },
          "azureBlobStorage": {
            "enabled": true,
            "sasUrl": "xxx"
          }
        },
        "failedRequestsTracing": {
          "enabled": "[parameters('enableFailedRequestTracing')]"
        },
        "detailedErrorMessages": {
          "enabled": "[parameters('enableDetailedErrorMessages')]"
        }
      }
    }
  ]
}

在不修改任何内容的情况下部署此模板时,config部分"logs"未正确部署+-1次2次.我刚刚再次测试了ARM模板,并且第一次部署时,Web应用程序没有用于诊断日志记录的正确设置.第二次都没有,但是第三次​​他们还好.但是第四次,设置不再正确.看起来模板的这一部分没有一致的行为.

When deploying this template without modifying anything, the config section 'logs' is not deployed correctly +- 1 on 2 times. I have just tested the ARM template again, and the first deployment, the web app had not the correct settings for diagnostics logging. The second time neither, but the third time they were ok. But the fourth time, the settings were not correct anymore. It looks like this part of the template has no consistent behavior.

我正在监督什么吗?

我尝试使用appsetting和日志创建WebApp,它对我来说正常工作.我使用Visual Studio创建了该项目.以下是我的详细步骤.

I try to create WebApp with the appsetting and logs, it works correctly for me. I created the project using Visual Studio. The following is my detail steps.

1.创建Azure资源项目

1.Create the Azure Resource Project

2.选择WebApp模板

2.Select the WebApp template

3.单击部署文件,然后右键单击并删除不必要的资源

3.Click the deploy file then right click and remove the unnecessary resource

4.为WebApp添加Appsetting资源

4.Add the Appsetting Resource for the WebApp

5.添加Azure WebApp的日志代码

5.Add the logs code for the Azure WebApp

{
          "apiVersion": "2015-08-01",
          "name": "logs",
          "type": "config",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
          ],
          "properties": {
            "applicationLogs": {
              "fileSystem": {
                "level": "Off"
              },
              "azureTableStorage": {
                "level": "Off"
              },
              "azureBlobStorage": {
                "level": "[variables('Level')]",
                "sasUrl": "xxxx"
              }
            },
            "httpLogs": {
              "fileSystem": {
                "enabled": false
              },
              "azureBlobStorage": {
                "enabled": true,
                "sasUrl": "xxxxxx"
              }
            },
            "failedRequestsTracing": {
              "enabled": "[parameters('enableFailedRequestTracing')]"
            },
            "detailedErrorMessages": {
              "enabled": "[parameters('enableDetailedErrorMessages')]"
            }
          }
        }

6.右键单击项目,然后选择部署

6.Right click the project and select the deploy

7.从Output and Azure门户检查结果

7.Check the result from the Output and Azure portal

整个手臂模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "hostingPlanName": {
      "type": "string",
      "minLength": 1
    },
    "enableFailedRequestTracing": {
      "type": "bool"
    },
    "enableDetailedErrorMessages": {
      "type": "bool"
    },
    "skuName": {
      "type": "string",
      "defaultValue": "F1",
      "allowedValues": [
        "F1",
        "D1",
        "B1",
        "B2",
        "B3",
        "S1",
        "S2",
        "S3",
        "P1",
        "P2",
        "P3",
        "P4"
      ],
      "metadata": {
        "description": "Describes plan's pricing tier and capacity. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
      }
    },
    "skuCapacity": {
      "type": "int",
      "defaultValue": 1,
      "minValue": 1,
      "metadata": {
        "description": "Describes plan's instance count"
      }
    }
  },
  "variables": {
    "webSiteName": "[concat('webSite', uniqueString(resourceGroup().id))]",
    "Level": "Error"
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('hostingPlanName')]",
      "type": "Microsoft.Web/serverfarms",
      "location": "[resourceGroup().location]",
      "tags": {
        "displayName": "HostingPlan"
      },
      "sku": {
        "name": "[parameters('skuName')]",
        "capacity": "[parameters('skuCapacity')]"
      },
      "properties": {
        "name": "[parameters('hostingPlanName')]"
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "[variables('webSiteName')]",
      "type": "Microsoft.Web/sites",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
        "displayName": "Website"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
      ],
      "properties": {
        "name": "[variables('webSiteName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
      },
      "resources": [
        {
          "name": "appsettings",
          "type": "config",
          "apiVersion": "2015-08-01",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', variables('webSiteName'))]"
          ],
          "tags": {
            "displayName": "appsettings"
          },
          "properties": {
            "key1": "value1",
            "key2": "value2"
          }
        },
        {
          "apiVersion": "2015-08-01",
          "name": "logs",
          "type": "config",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
          ],
          "properties": {
            "applicationLogs": {
              "fileSystem": {
                "level": "Off"
              },
              "azureTableStorage": {
                "level": "Off"
              },
              "azureBlobStorage": {
                "level": "[variables('Level')]",
                "sasUrl": "xxxxx"
              }
            },
            "httpLogs": {
              "fileSystem": {
                "enabled": false
              },
              "azureBlobStorage": {
                "enabled": true,
                "sasUrl": "xxxx"
              }
            },
            "failedRequestsTracing": {
              "enabled": "[parameters('enableFailedRequestTracing')]"
            },
            "detailedErrorMessages": {
              "enabled": "[parameters('enableDetailedErrorMessages')]"
            }
          }
        }
      ]
    }

  ]
 }