Добавление параметров журнала диагностики веб-приложения Azure в шаблон ARM

Я ищу возможность включить настройки журнала диагностики (уровень файла, а не blob) на этапе развертывания шаблона.
Я обнаружил следующее example на Github, однако он не работает, говоря "Microsoft.Web/sites/logs" is not a valid option".
Ниже приведена часть моего шаблона:

{
          "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
            }
          }
        },

Кроме того, я нашел после обсуждения аналогичного вопроса, но автор темы заявил, что этот фрагмент кода в большинстве случаев работает правильно.


person Sergey    schedule 16.03.2018    source источник
comment
создайте этот ресурс на портале и изучите его в проводнике ресурсов.   -  person 4c74356b41    schedule 16.03.2018
comment
На самом деле, я забыл об этом. Спасибо!   -  person Sergey    schedule 16.03.2018


Ответы (1)


Если вы хотите включить параметры журнала диагностики во время развертывания Azure WebApp. Для этого вы можете использовать следующий демонстрационный код. У меня корректно работает.

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"
    }
  }
}

Проверьте на портале Azure.

введите здесь описание изображения

person Tom Sun - MSFT    schedule 16.03.2018
comment
Я управлял своим развертыванием с помощью этой ссылки, однако в нем нет информации о applicationLogs или httpLogs, поэтому спасибо, что указали мне. - person Sergey; 16.03.2018