[Solved] Application Insights not working on Sitecore 9.1 PaaS

Avatar de Vinicius

A couple weeks ago I’ve asked a question in Sitecore Stackexchange explaining that the Sitecore 9.1 PaaS our team has provisioned in Azure was not providing data to the Application Insights.

I went through the existing post Accessing log files in application insitghts for Sitecore 9 in Azure app service which allowed me to execute some sort troubleshooting, and in summary here are the steps I reproduce

1.Check appinsights.instrumentationkey in ConnectionStrings.config

The idea is to verify if is not going to a different Application Insights or a typo occurred somewhere. Please check the Instrumentation Key from Azure Portal and at the ConnectionStrings.config

Check Application Insights Instrumentation Key Azure Sitecore Blog Vinicius Deschamps

2.Check the Daily Cap

Check Azure Application Insights Daily Volume Cap Blog Vinicius Deschamps

3.Check showconfig.aspx

Sitecore Admin showconfig.aspx Blog Vinicius Deschamps

4.Enable Live Metrics Stream

Azure Application Insights Live Metrics Blog Vinicius Deschamps

5.Enable Application map

On all roles, in the wwwroot/ApplicationInsights.config, uncomment the line containing the DependencyTrackingTelemetryModule. A caution though – it nearly doubles your ApplicationInsights data usage.

Azure Application Insights Application Map Blog Vinicius Deschamps

6.Querying Application Insights

– Go to the Application Insights resource and click the Analytics button on the Overview tab.
– The query builder will open. Paste in the following query:


| project timestamp, message, severityLevel, customDimensions.Role, customDimensions.InstanceName
| order by timestamp desc

Select the time range and click Run

Azure Application Insights Logs Blog Vinicius Deschamps

Another thing is that the Search shows results from Sitecore

Azure Application Insights Search Blog Vinicius Deschamps

Michael Baranov suggested the following

It’s a bug in 9.1.

To fix this you need:

Add telemetry module to ApplicationInsights.config

<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>

Add module to web.config under system.webserver

<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" 
        preCondition="integratedMode,managedHandler" />

And I did what he said but an Yellow Screen of Death showed up “Could not load file or assembly ‘Microsoft.AspNet.TelemetryCorrelation’ or one of its dependencies. The system cannot find the file specified” and I never heard back from him.

Frank Rosario, a colleague of mine here in Valtech, opened a ticket with Sitecore and they sent a hotfix for us.

For your reference if you face the same issue Ticket #527731

IMPORTANT: The following approach DOES NOT work without the hotfix provided by Sitecore, don’t give a shot by simply changing the files specified in the step “after the hotfix has been installed”

Accordingly to the Sitecore response

Be aware that the hotfix was built specifically for Sitecore XP 9.1 Initial Release, and you should not install it on other Sitecore versions or in combination with other hotfixes, unless explicitly instructed by Sitecore Support.

Note that you need to extract ZIP file contents to locate installation instructions and related files inside it.

Unless stated differently in the installation instructions, the hotfix should be installed on CM instance and then synced with other instances using your regular development practices

The hotfix should be install as a package, and will replace the following DLL libraries:


• /bin/Microsoft.ApplicationInsights.dll

• /bin/Microsoft.ApplicationInsights.TraceListener.dll

• /bin/Microsoft.AspNet.TelemetryCorrelation.dll

• /bin/System.Diagnostics.DiagnosticSource.dll

After the hotfix has been installed these steps must be taken

1.Edit ApplicationInsights.config. Under the ApplicationInsights\TelemetryModules paste the following line at the bottom of the section

<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web" />

Sitecore ApplicationInsights.config Blog Vinicius Deschamps

2.Edit web.config. Under the configuration/system.webServer/modules after <remove name="ApplicationInsightsWebTracking"/>, insert the following string:

<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler"/>

Sitecore Web Config Blog Vinicius Deschamps

Once you modify the files, restart the App Services and try to access it again to generate data for the Application Insights

Azure Application Insights working after Sitcore restart Blog Vinicius Deschamps

References and thanks

Mark Gibbons to write a terrific answer in how Application Insights works, and ways to troubleshoot it

Frank Rosario for opening the ticket with Sitecore

Sitecore for the amazing support

I hope you liked it, and I’ll see you on my next post!

Tagged in :

Avatar de Vinicius

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *