通过Azure Powershell启用带有配额和保留的Web服务器日志记录

时间:2015-10-02 17:04:58

标签: powershell azure

我在Powershell中寻找可以为Web服务器日志记录配置其他设置的命令:

azure diagnostics

到目前为止,我可以使用以下命令打开诊断程序:

Set-AzureWebsite HttpLoggingEnabled 1

是否有启用和设置保留以及配额的命令?

1 个答案:

答案 0 :(得分:1)

回应达米安的评论,是的,我确实解决了它!

您需要使用此配置块:

  # Configuration for enabling diagnostics, quota and retention with retention period.
  $PropertiesObject = @{
    httpLogs = @{
        fileSystem = @{
            enabled = $TRUE;
            retentionInMb = 35;
            retentionInDays = 7;
        }
    }
  }

并且您需要使用Set-AzureResource(如果您正在使用ARM,则可能是不同的cmdlet):

    # Apply the configuration to the web app.
    Set-AzureResource -PropertyObject $PropertiesObject `
      -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config `
      -ResourceName $ResourceName/logs -OutputObjectFormat New -ApiVersion 2015-08-01 -Force

我发现有用的一件事是使用resources.azure.com。我不确定您正在寻找什么,但这里是我使用该网站找到的其他配置块:

"properties": {
    "applicationLogs": {
      "fileSystem": {
        "level": "Off"
      },
      "azureTableStorage": {
        "level": "Off",
        "sasUrl": null
      },
      "azureBlobStorage": {
        "level": "Off",
        "sasUrl": null,
        "retentionInDays": null
      }
    },
    "httpLogs": {
      "fileSystem": {
        "retentionInMb": 100,
        "retentionInDays": 7,
        "enabled": true
      },
      "azureBlobStorage": {
        "sasUrl": null,
        "retentionInDays": 7,
        "enabled": false
      }