Fixing Application Insights Dependency Injection After Upgrading Microsoft.ApplicationInsights.WorkerService to 3.0.0
As part of our routine monthly maintenance on Azure Functions, we update NuGet packages to stay current and pick up bug fixes. This month that process led to a breaking change when we upgraded Microsoft.ApplicationInsights.WorkerService from version 2.23.0 to 3.0.0 on our .NET 8 Azure Functions. After the upgrade, our Application Insights logging stopped working entirely. Telemetry was no longer being captured, and it became clear that the dependency injection configuration in our Program.cs was the culprit. Here is what we had and how we fixed it. The Problem In version 2.23.0, we configured Application Insights in Program.cs like this: public static void Main(string[] args) { IHost host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() .ConfigureServices(s => { s.AddApplicationInsightsTelemetryWorkerService(options => { options.EnableAdaptiveSampling = false; }); s.ConfigureFunc...