I was working on ASP.NET Core 8 web API project to logging application in Azure Application insight and got the below warning:

ApplicationInsightsExtensions.AddApplicationInsightsTelemetry(IServiceColletcion, string) is obsolete

After doing some research I found the below solution.


Instead of :


We need to use

builder.Services.AddApplicationInsightsTelemetry(new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
    ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"],
    // Enable quick pulse
    EnableQuickPulseMetricStream = true,
    // Enable adaptive sampling
    EnableAdaptiveSampling = true,
    // Enable live metrics
    //EnableLiveMetrics = true,
    // Enable heart beat
    EnableHeartbeat = true


Leave a Reply

Your email address will not be published. Required fields are marked *