Create AppInsights instance for StaticWebApp via Bicep

Viewed 269

In the Azure Portal the Static Web App has a tab to link an Application Insights instance to the Static Web App: enter image description here

I'm looking for a way to configure this section via Bicep, but I can't find anything in the Microsoft docs about how to configure it.

So my question is how can I link an Application Insights instance to a Static Web App instance via Bicep template?

1 Answers

To link Application Insights instance into Static Web Apps there is no default Bicep/ARM template available.

We can achieve this by adding Application Insights Instrumentation key in your Static Web App Application Settings.

Set the APPINSIGHTS_INSTRUMENTATIONKEY setting in the config.

Add the child resources of Application Insights instrumentation key in your Static Web App Bicep Template.

  resource staticWebAppSettings 'config@2021-01-15' = {
    name: 'appsettings'
    properties: {
      APPINSIGHTS_INSTRUMENTATIONKEY: <your appInsightIntrumentationKey>
    }
  }

After Adding above step the Bicep/ARM templates works as expected.

Result

enter image description here Refer Github discussion to Add Application Insights into Static Web Application.

Related