Application Insights for your App Service in ARM the correct* way

*Correct in my opinion

I will assume you know how to configure the Application Insights resource itself in ARM. If you do not, you might want to go here first. It is also good to know that, to get the most out of Application Insights, you used to need to install a site extension in your App Service. This had some drawbacks, most notably that deployments with site extensions sometimes took a lot longer.

You might often see the following when navigating to the Application Insights option of your App Service (even thought your App Service is logging data to Application Insights):

This happens when you don’t set the instrumentation key in some variable you named yourself. Want to have a more useful page here… one that actually lets you navigate to the application insights. Like this:

This can be achieved by using the ‘magic’ setting key APPINSIGHTS_INSTRUMENTATIONKEY with the value being your Application Insights resource’s instrumentation key obviously. But wait, there is more:

This extra connection can be achieved by adding the following ‘magic’ setting to the App Service configuration: ApplicationInsightsAgent_EXTENSION_VERSION, set to a value of ‘~2’. You can set configuration settings in your ARM template by using the following basic structure:

"resources": [
  {
    "name": "appsettings",
    "type": "config",
    "apiVersion": "2015-08-01",
    "dependsOn": [
      "[resourceId('Microsoft.Web/sites', variables('webSiteName'))]"
    ],
    "properties": {
      "APPINSIGHTS_INSTRUMENTATIONKEY": "<your instrumentation key here>",
      "ApplicationInsightsAgent_EXTENSION_VERSION": "~2"
    }
  }
]

There are even more settings that you can use to control the different switches that are now available on the application insights page of you app service. The are described here.

Happy monitoring!

One thought on “Application Insights for your App Service in ARM the correct* way

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.