Search code examples
azure-functionsazure-application-insightsasp.net-core-3.1

Azure Functions v3 no longer auto-tracking dependencies after adding injected TelemetryConfiguration


Currently have an azure function v3 in .netcore 3.1 with the following host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false,
        "excludedTypes": "Exception"
      },
      "dependencyTrackingOptions": {
        "enableSqlCommandTextInstrumentation": true
      }
    },
    "logLevel": {
      "Function": "Information",
      "Host.Aggregator": "Information",
      "Host.Results": "Information",
      "default": "Warning"
    }
  }
}

Things were working fine with SQL dependencies being auto tracked in app insights. Needing to also track redis calls I've added telemetryClient via dependency injection as recommended with

telemetryClient = new TelemetryClient(telemetryConfiguration);

After doing this, however, I am only receiving dependency calls I manually write via telemetry client and no longer getting the default SQL calls.

I've tried manually creating a DependencyCollector.DependencyTrackingTelemetryModule and initializing it with the injected telemetryConfiguration and setting EnableSqlCommandTextInstrumentation = true , but although this does enable SQL tracing, it does not bind it to the calling context.

Has anyone run into this issue before or have any advice in how to properly implement custom telemetry while also maintaining default dependency tracking?


Solution

  • Downgraded Microsoft.Azure.WebJobs.Logging.ApplicationInsights to same version as Microsoft.NET.Sdk.Functions and it worked.