Error with DI for AppInsights
error CS1061: 'IServiceCollection' does not contain a definition for 'ConfigureFunctionsApplicationInsights' and no accessible extension method 'ConfigureFunctionsApplicationInsights' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
Here is my hostbuilder:
var host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() .ConfigureServices(s => { s.AddApplicationInsightsTelemetryWorkerService(); s.ConfigureFunctionsApplicationInsights(); s.AddLogging(); s.AddSingleton<IMyCustomInterface, MyCustomClass>(); }) .Build();
func start
generates
error CS1061: 'IServiceCollection' does not contain a definition for 'ConfigureFunctionsApplicationInsights' and no accessible extension method 'ConfigureFunctionsApplicationInsights' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
Here are the relevant packages from my .csproject
<ItemGroup> <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.2.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.14.0" /> <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> </ItemGroup>
Commenting out the call to ConfigureFunctionsApplicationInsights(); allows logging to work.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 6ad5f362-cbfb-0621-4389-6378f50359e4
- Version Independent ID: ebf1a8f3-ab9d-d295-e3a4-a982ed9df1e9
- Content: Guide for running C# Azure Functions in an isolated worker process
- Content Source: articles/azure-functions/dotnet-isolated-process-guide.md
- Service: azure-functions
- GitHub Login: @ggailey777
- Microsoft Alias: glenga