Announcing Application Insights integration with App Service Diagnostics

4 minute read • By Puneet Gupta • April 21, 2020

App Services Diagnostics is a powerful tool that allows you to troubleshoot and mitigate issues within your application. The rich set of tools under the App Services Diagnostics carefully analyze all the telemetry emitted by App Services platform and suggests recommendations and troubleshooting steps that help in keeping your apps up and healthy. We are happy to announce that App Services Diagnostics has now deeper and better integration with Application Insights.

With the click of a button, you can connect an Application Insights resource with App Service diagnostics and bring together the best of both worlds, allowing you to troubleshoot and debug your applications more effectively. With the rich information about the platform and application telemetry combined together, you are presented with a streamlined view of the issues encountered and this enables you to identify problems easily. Should you open a support case with Microsoft and consent to share diagnostics, this will also enable Microsoft support engineers to review the information from both the platform and App Insights to help you swiftly resolve your case.

How to Enable Application Insights integration with App Service Diagnostics

Enabling Application insights integration is as easy as clicking a button in App Services Diagnostics. To enable this feature, visit the Diagnose and Solve blade for your app and choose Availability and Performance.

Landing Page

If Application Insights is not integrated for your app already, you will see an option to Enable Application Insights right from this view.

Enable Application Insights

And if Application Insights is already enabled, then you will get an option to Connect it with App Services Diagnostics.

Connect with Application Insights

This connects the Application Insights resource for the app to App Service Diagnostics and allows you to view the exceptions and dependency information for the app within App Service Diagnostics. At the same time, any engineers engaged with you from Microsoft Support are enabled to leverage this information, provided you have given consent to share diagnostics information while creating a Support case.

Application Insights Connected

What to expect after enabling Application Insights Integration

After enabling App Insights Integration feature, App Service Diagnostics starts leveraging App Insights telemetry and points you to exceptions and dependency slowness information in different views that you typically use to diagnose issues. Here is an example of the HTTP Server Errors view changes with Application Insights information.

Application Insights Detector View

And drilling down into the HTTP Server Errors view, you can find all details about the failed requests corresponding to the Exceptions in the same view. As you can see below, the table shows you the exception information, exception message, and the method in the code that was responsible for causing the exception. With the help of this integration, you can not only view the platform issues but also correlate any application issues that caused availability drops to the app.

Exceptions from Application Insights

What happens after you Integrate Application Insights with App Service Diagnostics

When you click Connect, an API key for your Application Insights is generated with read-only access to the telemetry and this API key along with the AppId for the Application Insights resource are stored as a hidden tag in ARM at the Azure App Service app level. At the App Insights Resource level, you may see something like this.

Application Insights API Access

On the App Services side, you should see a new tag created at the app level with the name hidden-related:diagnostics/applicationInsightsSettings. You can view this tag by going to Azure Resource Explorer (https://resources.azure.com). The AppId is stored as is, but the API Key is encrypted using an internal key, so it is kept protected and not left as clear text.

Using this information, App Services Diagnostics can query the Application Insights resource and is able to merge both the experiences together. For Microsoft support and engineering teams, an equivalent internal tool is available and engineers and engineering teams assisting you on your incidents opened with Microsoft can access this information in similar unified troubleshooting experience.

How to disable App Insights Integration

We are working on a user interface that allows you to disable this feature easily under Diagnose and Solve problems. Until then, you can use a PowerShell Script example like this to simple disable the AppInsights integration feature.

Login-AzureRmAccount
$subId = "<Azure_Subscription_ID>"
$rg ="<ResourceGroupName>"
$appName = "AppName"
$resourceId = "/subscriptions/$subId/resourceGroups/$rg/providers/Microsoft.Web/sites/$appName"
$webApp = Get-AzureRmResource -ResourceId $resourceId
$updatedTags = @{}

foreach($t in $webApp.Tags.GetEnumerator())
{
    if ($t.Key -ne "hidden-related:diagnostics/applicationInsightsSettings")
    {
        $updatedTags.Add($t.Key, $t.Value)
    }
}

Set-AzureRmResource -ResourceId $resourceId -Tag $updatedTags

Next steps

So, what are you waiting for :smiley:? Integrate your application with Application Insights and get the unified experience that brings the best of both worlds. We just want to close by sharing some articles around Application Insights.

For more information on App Service Diagnostics, please visit Azure App Service diagnostics overview.

Feel free to share your feedback or questions about App Service Diagnostics by emailing diagnostics@microsoft.com or posting on UserVoice with “[Diag]” in the title.