1

I am trying to enable Azure Application Insights Auto Instrumentation for my existing ASP.NET web application hosted on App Service. It does not work, so I try to investigate and found this section from https://learn.microsoft.com/en-us/troubleshoot/azure/azure-monitor/app-insights/auto-instrumentation-troubleshoot?source=recommendations

A diagnostics library was detected

Auto-instrumentation fails if it detects the following libraries:

System.Diagnostics.DiagnosticSource
Microsoft.AspNet.TelemetryCorrelation
Microsoft.ApplicationInsights

These libraries must be removed for auto-instrumentation to succeed.

In my case, my web application has a dependency on System.Diagnostics.DiagnosticSource. But to my surprise, this library is a transitive dependency for Azure.Core, and most of the sdks to connnect with Azure services have a dependency on Azure.Core. And it is very unlikely that we want to deploy a web app on Azure without connecting to Azure services.

So does this mean that it is nearly impossible to use the auto instrumentation on a non-trivial app?

asinkxcoswt
  • 2,252
  • 5
  • 29
  • 57
  • 2
    I think so. On the other hand, adding the Nuget package, passing the connection string and write a single line of code to init the package is hardly any work so you might be better off just doing that. – Peter Bons Mar 27 '23 at 19:22
  • 1
    Yes, I do agree with Peter Bons. In this case it is advised to add Application Insights manually, it will not take much time and configuration can be done easily. – Harshitha Mar 28 '23 at 05:38
  • What is the .NET Version you are using ? – Harshitha Mar 28 '23 at 07:18

1 Answers1

3

Isn't it nearly impossible to use Azure Application Insights Auto Instrumentations for .NET?

Thanks @Peter Bons for the comment.

As per this MSDoc, Auto Instrumentation is supported for

Windows - .NET Core LTS Linux - Only ASP.NET Core 6.0.

Please check the auto-instrumentation supported environments.

It is not impossible, but Auto-Instrumentation may not track all the required telemetry data as you have specified.

To avoid all this, it is advised to configure the Application Insights Manually.

  • Auto-Instrumentation works well when you you want to track data for easy and small Application.

  • If you want to track any custom events and metrics, then better to go with manual Application Insights.

In appsettings.json file add the ApplicationInsights ConnectionString.

Refer the below links

Harshitha
  • 3,784
  • 2
  • 4
  • 9