azure - ARM 模板应用程序服务配置 - 竞争条件/行为不一致

标签 azure azure-resource-manager azure-web-app-service azure-rm-template azure-app-service-plans

使用下面的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
                          }
                    }
                }       
            ]
        }
    ]
}

最佳答案

您应该将应用设置与 functionApp 资源 一起配置,而不是在单独的资源中定义设置。我已经使用了它并定义了各种应用程序设置,并且运行良好。请尝试像下面的示例一样。

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

关于azure - ARM 模板应用程序服务配置 - 竞争条件/行为不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53013383/

相关文章:

azure - 将 Azure Blob 存储帐户链接到 Azure 数据工厂时出错

Azure Databricks CLI : update workflow/job definition

azure - 通过 ARM 模板在本地部署上使用 [deployment().properties.templateLink.uri]

azure - 哪个 Azure 区域是 "North Central US"

asp.net - 尝试访问 Azure Web 应用程序中的特定页面时发生错误

azure - 如果网站在 AWS EC2 和 Azure VM 上运行,Videojs 会记录不访问摄像头/麦克风或共享屏幕的情况

Azure 事件网格出站限制

azure - 通过 CLI 将 Azure 资源管理器模板部署到现有 VNET

azure - 将某些 API 请求从一个 Web 应用程序重定向到另一个 Web 应用程序

azure - 如何将 azure cli list 命令的值获取到变量中?