0

I created a static web app (basically just a few HTML files) and added an API. Both work fine: I can access the web app (https://icy-tree-xyz.1.azurestaticapps.net), and I can successfully call the API (https://icy-tree-xyz.1.azurestaticapps.net/api/testfunction).

  • Then I open the app settings in the azure portal
  • click on "Application Insights"
  • click "enable"
  • click "create new" and create a new instance
  • click "save"

Everything seems to be OK. But when I change to a different setting like "custom domains" and back again, that application insights settings are gone. It "forgets" them somehow.

metanoia
  • 21
  • 3

3 Answers3

0

I solved it by creating the app insights instance first and then connecting it to the static website.

metanoia
  • 21
  • 3
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 20 '22 at 00:58
0

Found a resolution. While adding APPINSIGHTS_INSTRUMENTATIONKEY (with the corresponding instrumentation key as the value) to the configuration of the Azure Static Webapp, the setting was saved.

ouflak
  • 2,458
  • 10
  • 44
  • 49
0

Even though the settings in the Application Insights blade are gone (in my case, I always had the App Insights is only applicable to Static Web Apps with at least one function. Add a function to your app to enable App Insights error), the telemetry is still being sent to the App Insights instance in my case.

I am deploying a React frontend App on a Static Web App, and a Node backend on App Service (Web App, not Function App). After having deployed both, running the command below effectively connected the two via the APIs blade in the Static Web App, and telemetry started to be sent to a previously deployed App Insights instance, that was already connected to the backend.

az staticwebapp backends link --backend-resource-id /subscriptions/xxxxxxxx-yyyy-zzzz-hhhh-kkkkkkkkkk/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/my-webapp-name \
                              --name my-static-webapp-name \
                              --resource-group my-webapp-resource-group \
                              --backend-region my-webapp-region
ccoutinho
  • 3,308
  • 5
  • 39
  • 47