0
votes

I'm deploying an Azure Web App using the Microsoft.Azure.Management.Websites SDK.

I can create the web app fine with WebSiteManagementClient.Sites.CreateOrUpdateSite(). However one element that I can't seem to configure is the Diagnostics logging.

In the new Azure Portal, I can open "Diagnostics logs" and define both the "Application Logging" and "Web server logging" to use Blob storage.

I'm unable to see any options in the SDK libraries for configuring this - anyone have any ideas? I'm open to using ARM Templates if need be.

Thanks in advance

2
Hi Joel, will you accept the ARM template solution for this as answer? I am not sure about how to achieve this with Azure SDK but am sure with ARM template.juvchan
@juvchan Absolutely, thanksJoel Gallagher

2 Answers

0
votes

Solved : The method WebSiteManagementClient.Sites.UpdateSiteLogsConfig() is where the diagnostics get defined

0
votes

Alternatively, you can also configure the diagnostic logs to enable the use of blob storage for logging for web app with the ARM template section below.

{
  "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'))]"
  ]
}