Home > Net >  How to get the full SQL query in Application Insights
How to get the full SQL query in Application Insights

Time:12-16

I just watched the video enter image description here

CodePudding user response:

  • By default, SQL Collection is set to off. We need to enable it in the Azure Portal.
  • To get the full SQL Query, we need to enable the SQL Commands in our deployed App Service => Application Insights.

enter image description here

  • Add the below line of code in Program.cs file, if it is .NET Core Applications.
builder.Services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });
  • If it is .NET Framework Application, add the below line in TelemetryModules section in ApplicationInsights.config file (which is generated when we add Application Insights in Visual Studio.
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">, 
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>

References taken from MSDoc and GitHub.

  • Related