.NET 8 In-Process function does not work if it references any packages that add Keyed Services to the collection (eg. Polly).
Microsoft.Azure.WebJobs.Script: Error configuring services in an external startup class.
Microsoft.Extensions.DependencyInjection.Abstractions: This service descriptor is keyed. Your service provider may not support keyed services.
Investigative information
Happens locally running in the Visual Studio emulator, as well as if deployed to Azure.
Seems to be due to the code in ConfigureAndLogUserConfiguredServices method of WebJobsBuilderExtensions checking the ImplementationType of all registered services, this throws an exception if a keyed service is registered.
Repro steps
Create an Azure Function using .NET 8.0 In-Process model.
Add a reference to Polly 8.4.1 from Nuget
Add the following code to Startup class's Configure method:
#### Expected behavior
Function app starts up as expected.
#### Actual behavior
Function App fails to start up:
Microsoft.Azure.WebJobs.Script: Error configuring services in an external startup class.
Microsoft.Extensions.DependencyInjection.Abstractions: This service descriptor is keyed. Your service provider may not support keyed services.
This is particularly dangerous because some Nuget packages change their behaviour when .net 8 is targeted and will perform a keyed registration - if ANY referenced package does this, the function app will not start up.
.NET 8 In-Process function does not work if it references any packages that add Keyed Services to the collection (eg. Polly).
Investigative information
Happens locally running in the Visual Studio emulator, as well as if deployed to Azure.
Seems to be due to the code in ConfigureAndLogUserConfiguredServices method of WebJobsBuilderExtensions checking the ImplementationType of all registered services, this throws an exception if a keyed service is registered.
Repro steps
Microsoft.Azure.WebJobs.Script: Error configuring services in an external startup class. Microsoft.Extensions.DependencyInjection.Abstractions: This service descriptor is keyed. Your service provider may not support keyed services.