azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Azure Functions Tools gives runtime error using Application Insights 2.16

Open FiddlerKing opened this issue 4 years ago • 10 comments

Got a very simple function to illustrate the problem:

[FunctionName("Function1")]
public void Run([TimerTrigger("0 */5 * * * *", RunOnStartup =true)]TimerInfo myTimer, ILogger log)
{
    var requestActivity = new System.Diagnostics.Activity($"Test");
    requestActivity.SetIdFormat(System.Diagnostics.ActivityIdFormat.W3C);
    requestActivity.SetParentId(Guid.Empty.ToString());

    using (var activity = telemetryClient.StartOperation<Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry>(requestActivity))
    {
    }
}

Running that function gives this error: Executed 'Function1' (Failed, Id=5d9ccc3f-2e1d-4f0a-b235-6384b86ae777, Duration=4258ms) System.Private.CoreLib: Exception while executing function: Function1. TestApp1: Method not found: 'Microsoft.ApplicationInsights.Extensibility.IOperationHolder`1<!!0> Microsoft.ApplicationInsights.TelemetryClientExtensions.StartOperation(Microsoft.ApplicationInsights.TelemetryClient, System.Diagnostics.Activity)'.

Downgrading Application Insights to 2.15 or 2.14 solves the problem. TelemetryClient is injected.

This happens on the latest updates of VS2019 (16.8.4). What am I doing wrong here? Or is Functions Tools not compatible with AI 2.16?

FiddlerKing avatar Jan 22 '21 12:01 FiddlerKing

@brettsam could you please take a look at this?

apawast avatar Jan 26 '21 18:01 apawast

@brettsam double checking, but this looks like a breaking change in 2.16

fabiocav avatar Jan 28 '21 21:01 fabiocav

any update on this? seems it's quite brittle when using different nuget package versions than included in runtime, are there any best practice setting up dependency injection?

smartpcr avatar Feb 27 '21 11:02 smartpcr

I'm having the same issue and I had to downgrade application insights version and suppress version downgrade errors. Any update on this?

CarlosLanderas avatar Apr 06 '21 10:04 CarlosLanderas

@CarlosLanderas I tried downgrading as well but it didn't work. Which version did you downgrade to?

vyarymovych avatar Apr 28 '21 08:04 vyarymovych

@vyarymovych 2.14 is working properly I'm now able to do distributed tracing by starting operations using System.Diagnostics.Activity

CarlosLanderas avatar Apr 28 '21 08:04 CarlosLanderas

@CarlosLanderas thanks, I just tried again and still the same error. Sending the package versions that I use Capture_Packages Capture_Error

vyarymovych avatar Apr 28 '21 09:04 vyarymovych

2.17 is also broken. Reverting to 2.14 does work

snapfisher avatar May 06 '21 02:05 snapfisher

Faced the same issue upgrading to v2.18. Reverting to v2.14 works.

santhoshtns avatar Dec 01 '21 16:12 santhoshtns

Is this issue expected to be fixed now with Azure/azure-functions-host/pull/8041 merged?

JatinSanghvi avatar Aug 05 '22 10:08 JatinSanghvi