4

Is there a way to disable Application Insights in a ASP.NET Web app? Suppose I want to switch off all data collection in an app running in production.

mstrand
  • 2,973
  • 5
  • 24
  • 26

1 Answers1

4

if the ikey is in the ApplicationInsights.config file, you can remove it from the config file and it should stop sending data.

if the ikey is somewhere else, you'll have to disable via code:

TelemetryConfiguraiton.Active.DisableTelemetry

see: https://github.com/Microsoft/ApplicationInsights-dotnet/blob/1648ecd5bf32cc151557d15cbb0886cb86e84270/src/Core/Managed/Shared/Extensibility/TelemetryConfiguration.cs#L96

worst worst case you could always prevent outbound web requests to dc.services.visualstudio.com, where AI would be sending the data.

John Gardner
  • 24,225
  • 5
  • 58
  • 76
  • Would be nice to have the TelemetryConfiguraiton.Active.DisableTelemetry as an configuration file option – mstrand Nov 17 '15 at 08:34
  • The Configuration method in the Startup.cs class is a good place to put 'TelemetryConfiguration.Active.DisableTelemetry = true;'. Also need to add the 'using Microsoft.ApplicationInsights.Extensibility;' statement to the usings section at the head of the file, too. – Brett Rigby Apr 05 '18 at 07:43