Home > Software design >  Application Insights not logging SQL Dependencies queries
Application Insights not logging SQL Dependencies queries

Time:09-24

I'm using an App service hosted in Azure using Asp.Net Core & .Net5. I turned on SQL dependency tracking using below settings in appSettings.config. But I see SQL dependencies logged without SQL command Text. Is there any other settings to enable to see SQL commands in the log?

  "ApplicationInsights": {
    "InstrumentationKey": "my guid key",
    "EnableDependencyTracking": true,
    "DependencyTrackingOptions": {
      "EnableSqlCommandTextInstrumentation": true
    },
    "sampling": {
      "isEnabled": true,
      "maxTelemetryItemsPerSecond": 5
    }
  },

CodePudding user response:

Your settings in appSettings.config is for Azure Function, not ASP.NET Core applications.

For ASP.NET Core applications, It is now required to opt-in to SQL Text collection by using

services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module. EnableSqlCommandTextInstrumentation = true; });

For more details, you can refer official doc

Advanced SQL tracking to get full SQL Query

  • Related