Search code examples
azureazure-application-insightsazure-bicepazure-diagnosticsazure-web-pubsub

How to enable diagnostics with bicep for Azure Web PubSub?


The Azure WebPub bicep documentation mentions nothing about how to enable diagnostic settings to stream logs to a log analytics workspace, but the Azure Portal has an interface for it.

https://learn.microsoft.com/en-us/azure/templates/microsoft.signalrservice/2021-10-01/webpubsub?pivots=deployment-language-bicep

I am guessing that I have to create a Microsoft.Insights/diagnosticSettings resource, buy the same thing applies here. No apparent documentation.

How do I enable diagnostics with bicep for Azure Web PubSub?

enter image description here


Solution

  • Thanks for getting me in the right direction @Thomas. Your category names were a bit off and I also needed a workspaceId in the properties. After many attempts I got the category names by simply exporting my manual configuration to ARM and saw that the names should be as below.

    resource webPubSubDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
      name: '${webPubSubName}-DiagnosticSettings' 
      scope: webpubsub
      properties: {
        workspaceId: logAnalyticsWorkspace.id
        logs: [
          {
            category: 'ConnectivityLogs'
            enabled: true
          }
          {
            category: 'MessagingLogs'
            enabled: true
          }
          {
            category: 'HttpRequestLogs'
            enabled: true
          }
        ]
        metrics: [
          {
            enabled: true
            category: 'AllMetrics'
          }
        ]
      }
    }