包含 Web 应用程序配置设置的 ARM 模板 [英] ARM Template containing config settings for web app

查看:14
本文介绍了包含 Web 应用程序配置设置的 ARM 模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am encountering strange behavior when deploying an ARM template.

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

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.

Am I overseeing something?

解决方案

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.Create the Azure Resource Project

2.Select the WebApp template

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

4.Add the Appsetting Resource for the 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.Right click the project and select the deploy

7.Check the result from the Output and Azure portal

The whole arm template:

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

  ]
 }

这篇关于包含 Web 应用程序配置设置的 ARM 模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆