【问题标题】:How to use BlobStorage for Azure Web App Diagnostics logs (using SDK)如何将 BlobStorage 用于 Azure Web 应用诊断日志(使用 SDK)
【发布时间】:2017-03-03 04:11:53
【问题描述】:

我正在使用 Microsoft.Azure.Management.Websites SDK 部署 Azure Web 应用程序。

我可以使用 WebSiteManagementClient.Sites.CreateOrUpdateSite() 创建 Web 应用程序。但是,我似乎无法配置的一个元素是诊断日志记录。

在新的 Azure 门户中,我可以打开“诊断日志”并定义“应用程序日志记录”和“Web 服务器日志记录”以使用 Blob 存储。

我在 SDK 库中看不到任何用于配置此功能的选项 - 有人有什么想法吗?如果需要,我愿意使用 ARM 模板。

提前致谢

【问题讨论】:

  • 您好 Joel,您会接受 ARM 模板解决方案作为答案吗?我不确定如何使用 Azure SDK 实现这一点,但可以确定使用 ARM 模板。
  • @juvchan 非常感谢

标签: azure azure-web-app-service azure-blob-storage diagnostics azure-diagnostics


【解决方案1】:

已解决:方法 WebSiteManagementClient.Sites.UpdateSiteLogsConfig() 是定义诊断的地方

【讨论】:

    【解决方案2】:

    或者,您还可以配置诊断日志,以启用 blob 存储,以便使用下面的 ARM 模板部分记录 Web 应用程序。

    {
      "type": "Microsoft.Web/sites",
      "name": "[parameters('webapp_name')]",
      "apiVersion": "2015-08-01",
      "location": "Southeast Asia",
      "properties": {
        "name": "[parameters('webapp_name')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_name'))]"
      },
      "resources": [
        {
          "name": "logs",
          "type": "config",
          "apiVersion": "2015-08-01",
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('webapp_name'))]"
          ],
          "properties": {
            "applicationLogs": {
              "fileSystem": {
                "level": "Off"
              },
              "azureTableStorage": {
                "level": "Off",
                "sasUrl": null
              },
              "azureBlobStorage": {
                "level": "Verbose",
                "sasUrl": "yourBlobStorageSasUrl",
                "retentionInDays": null
              },
              "httpLogs": {
                "fileSystem": {
                  "retentionInMb": 35,
                  "retentionInDays": null,
                  "enabled": false
                },
                "azureBlobStorage": {
                  "sasUrl": "yourBlobStorageSasUrl",
                  "retentionInDays": null,
                  "enabled": true
                }
              }
            }
          }
        }
      ],
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_name'))]"
      ]
    }
    

    【讨论】:

    • 感谢 - 我使用 SDK 方法解决了这个问题,但将来会记住 ARM 模板
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    相关资源
    最近更新 更多