Custom ITelemetryInitializer in azure function .Net Core 3.1 does not work
See original GitHub issueCustom ITelemetryInitializer
in azure function .Net Core 3.1 does not work.
I’ve implemented a custom ITelemetryInitializer and injected using Dependency injection as Singleton but Initialize
method of ITelemetryInitializer
of custom class is not hit.
Repro steps
- Created a new .Net core 3.1 Azure function with Http binding.
- Installed Microsoft.Azure.Functions.Extensions 1.0.0 package
- Installed Microsoft.ApplicatoinInsights 2.13.1 package
Created a new Custom ITelemetryInitializer
class
public class MyCustomTelemetryInitializer : ITelemetryInitializer
{
public MyCustomTelemetryInitializer()
{
}
public void Initialize(ITelemetry telemetry)
{
if (telemetry == null)
{
return;
}
telemetry.Context.GlobalProperties["SomePropertyName"] = "SomePropertyValue";
}
}
Added Startup implemenation
[assembly: FunctionsStartup(typeof(SomeNamespace.Startup))]
namespace SomeNamespace
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddSingleton<ITelemetryInitializer, MyCustomTelemetryInitializer>();
}
}
}
The configure method is hit (If I hit the breakpoint) but breakpoint at MyCustomTelemetryInitializer
is never hit and due to that the custom telemetry properties are not injected.
Expected behavior
The custom properties injected by MyCustomTelemetryInitializer
should be logged.
Actual behavior
The custom properties injected by MyCustomTelemetryInitializer
are NOT being logged.
Known workarounds
NA
Related information
- .Net Core : 3.1
- Microsoft.NET.Sdk.Functions - 3.0.1
- Microsoft.Azure.Functions.Extensions 1.0.0
- Microsoft.ApplicatoinInsights 2.13.1
Tried downgrading the Microsoft.ApplicatoinInsights to 2.11.0 but still did not work.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
I have the same issue, and I am using Microsoft.NET.Sdk.Functions 4.0.1. Please help me, thank you.
Any updates? .Net 6.0 isolated