AMoghrabi
AMoghrabi

Reputation: 353

Enable Web Server Logging With Quota and Retentions through Azure Powershell

I'm looking for a command in Powershell that can configure additional settings for Web Server Logging:

azure diagnostics

So far I can turn on diagnostics with the command:

Set-AzureWebsite HttpLoggingEnabled 1

Are there commands to enable and set retention as well as the quota?

Upvotes: 1

Views: 399

Answers (1)

AMoghrabi
AMoghrabi

Reputation: 353

In response to Damian's comment, yes, I did solve it!

You'll need to use this configuration block:

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

And you'll need to use the Set-AzureResource (may be a different cmdlet if you're using ARM):

    # 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

One thing I found helpful is using resources.azure.com. I'm not sure what you're looking for exactly, but here are other config blocks I found using that website:

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

Upvotes: 1

Related Questions