I am so confused while enabling logging in azure functions in .NET Core 6 using application insights. I had explored lot of sites but still in dilemma what exactly the difference between the nuget packages and when to use at which situations.
microsoft.extensions.logging.applicationinsights
microsoft.applicationinsights.aspnetcore
I had understand that if we want custom telemetry, we should use microsoft.applicationinsights.aspnetcore
I had created separate azure functions with separate nuget packages and I am able to see logs.
With microsoft.extensions.logging.applicationinsights package and used ILogger in function classes.
I added below piece of code in azure function startup
builder.Services.AddSingleton(new TelemetryConfiguration { ConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING")});
with Microsoft.ApplicationInsights.AspNetCore package , I injected Di and used ITelemetryClient in function classes
I added below piece of code in azure function startup
var options = new ApplicationInsightsServiceOptions { ConnectionString = SharedMethods.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING") };
builder.Services.AddApplicationInsightsTelemetry(options);