诊断日志设置添加到

诊断日志设置添加到

本文介绍了将 Azure Web App 诊断日志设置添加到 ARM 模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在寻找在模板部署阶段启用诊断日志设置(文件级别,而不是 Blob)的选项.
我在 Github 上找到了以下

I'm looking for the option to enable diagnostic log settings (file level, not blob) on the template deployment stage.
I've found the following example on Github however, it doesn't work, saying "Microsoft.Web/sites/logs" is not a valid option".
Below is the part of my template:

{
          "apiVersion": "2015-08-01",
          "name": "logs",
          "type": "config",
          "location": "[resourcegroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
          ],
          "properties": {
            "applicationLogs": {
              "fileSystem": {
                "level": "Verbose"
              }
            },
            "httpLogs": {
              "fileSystem": {
                "retentionInMb": 100,
                "retentionInDays": 90,
                "enabled": true
              }
            },
            "failedRequestsTracing": {
              "enabled": true
            },
            "detailedErrorMessages": {
              "enabled": true
            }
          }
        },

Also, I've found the following discussion on a similar question but the topic starter stated that this piece of code works correctly in most cases.

解决方案

If you want to enable diagnostic log settings during deployment Azure WebApp. You could use the follow demo code to do that. It works correctly on my side.

Deploy.json

{
      "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "siteName": {
          "type": "string"
        },
        "appServicePlanName": {
          "type": "string"
        },
        "siteLocation": {
          "type": "string"
        },
        "workerSize": {
          "type": "string",
          "allowedValues": [
            "0",
            "1",
            "2"
          ],
          "defaultValue": "1"
        }
      },
      "resources": [
        {
          "apiVersion": "2015-08-01",
          "name": "[parameters('appServicePlanName')]",
          "type": "Microsoft.Web/serverfarms",
          "location": "[parameters('siteLocation')]",
          "sku": {
            "name": "S1",
            "tier": "Standard",
            "capacity": 1
          },
          "properties": {
            "name": "[parameters('appServicePlanName')]"
          }
        },
        {
          "apiVersion": "2015-08-01",
          "name": "[parameters('siteName')]",
          "type": "Microsoft.Web/sites",
          "location": "[parameters('siteLocation')]",
          "dependsOn": [
            "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
          ],
          "properties": {
            "serverFarmId": "[parameters('appServicePlanName')]"
          },
          "resources": [
            {
              "apiVersion": "2015-08-01",
              "name": "logs",
              "type": "config",
              "dependsOn": [
                "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
              ],
              "properties": {
                "applicationLogs": {
                  "fileSystem": {
                    "level": "Verbose"
                  }
                },
                "httpLogs": {
                  "fileSystem": {
                    "retentionInMb": 100,
                    "retentionInDays": 90,
                    "enabled": true
                  }
                },
                "failedRequestsTracing": {
                  "enabled": true
                },
                "detailedErrorMessages": {
                  "enabled": true
                }
              }
            }
          ]
        }
      ]
    }

parameters.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "siteName": {
      "value": "xxxxxx"
    },
    "appServicePlanName": {
      "value": "xxxx"
    },
    "siteLocation": {
      "value": "East US"
    },
    "workerSize": {
      "value": "1"
    }
  }
}

Check from the Azure portal.

这篇关于将 Azure Web App 诊断日志设置添加到 ARM 模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 09:51