Jonathan Niu
Jonathan Niu

Reputation: 321

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?

Upvotes: 0

Views: 519

Answers (1)

Jonathan Niu
Jonathan Niu

Reputation: 321

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

Upvotes: 1

Related Questions