【问题标题】:ARM Template App Service Config - Race Condition / Inconsistent BehaviorARM 模板应用服务配置 - 竞争条件/不一致的行为
【发布时间】:2018-10-26 17:04:52
【问题描述】:

使用下面的 ARM 模板,我们 enabled diagnostic settings for our app service 以及在 resources 元素下定义 appSettings 配置。问题是在从模板部署我们的应用服务后间歇性地 - appSettings 没有被分配,但诊断设置是。

如果有更好的方法为logsappSettings 定义配置以提供更一致的站点输出的应用服务,有人可以指导我们吗?我们每天为 PR 构建和拆除数十个应用程序服务,因此这一点非常明显。

appSetting WEBSITE_LOAD_USER_PROFILE 将在创建应用服务时随机删除。我们是缺少dependsOn 还是需要升级apiVersion

带有应用设置 + 日志配置的 ServerFarm

{
    "$schema": "http://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "siteName": {
            "type": "string"
        },
        "siteHostingPlanName": {
            "type": "string"
        },
        "resourceLocation": {
            "type": "string"
        }
    },
    "resources": [  
        {
            "apiVersion": "2016-09-01",
            "name": "[parameters('siteHostingPlanName')]",
            "type": "Microsoft.Web/serverfarms",
            "location": "[parameters('resourceLocation')]",
            "properties": {
                "name": "[parameters('siteHostingPlanName')]"
            },
            "sku": {
                "name": "P2V2",
                "tier": "PremiumV2",
                "capacity": 2
            }
        },
        {
            "apiVersion": "2014-11-01",
            "name": "[parameters('siteName')]",
            "type": "Microsoft.Web/sites",
            "location": "[parameters('resourceLocation')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', parameters('siteHostingPlanName'))]"
            ],
            "properties": {
                "name": "[parameters('siteName')]",
                "serverFarm": "[parameters('siteHostingPlanName')]",
                "siteConfig": {
                    "AlwaysOn": true,
                    "webSocketsEnabled": true,
                    "http20Enabled": true,
                    "requestTracingEnabled": true,
                    "requestTracingExpirationTime": "9999-12-31T23:59:00Z",                    
                    "httpLoggingEnabled": true,
                    "logsDirectorySizeLimit": 100,
                    "detailedErrorLoggingEnabled": true
                }
            },
            "resources": [
                {
                    "apiVersion": "2014-11-01",
                    "name": "appsettings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
                    ],
                    "properties": {
                        "WEBSITE_LOAD_USER_PROFILE": 1
                    }
                },
                {
                    "apiVersion": "2014-11-01",
                    "name": "logs",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
                    ],
                    "properties": {
                        "applicationLogs": {
                            "fileSystem": {
                              "level": "Verbose"
                            }
                          },
                          "httpLogs": {
                            "fileSystem": {
                              "retentionInMb": 100,
                              "enabled": true
                            }
                          },
                          "failedRequestsTracing": {
                            "enabled": true
                          },
                          "detailedErrorMessages": {
                            "enabled": true
                          }
                    }
                }       
            ]
        }
    ]
}

【问题讨论】:

    标签: azure azure-resource-manager azure-web-app-service arm-template azure-app-service-plans


    【解决方案1】:

    您应该将应用设置与functionApp Resource 一起配置,而不是在单独的资源中定义设置。我已经使用它并定义了各种应用程序设置,它工作正常。试试下面的例子。

    {
          "apiVersion": "[variables('sitesApiVersion')]",
          "type": "Microsoft.Web/sites",
          "kind": "functionapp",
          "location": "[resourceGroup().location]",
          "name": "[parameters('functionAppName')]",
          "scale": null,
          "properties": {
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('functionApp_appServicePlanName'))]",
            "siteConfig": {
              "appSettings": [
                {
                  "name": "WEBSITE_LOAD_USER_PROFILE",
                  "value": "1"
                }
               ]
            },
            "dependsOn": [
              "[resourceId('Microsoft.Web/serverfarms', parameters('functionApp_appServicePlanName'))]",
              "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ]
          }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多