Skip to content

In-Process .NET 8.0 upgrade errors: This service descriptor is keyed. Your service provider may not support keyed services. #10312

Closed as not planned
@gallivantor

Description

@gallivantor

.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.

image

Repro steps

  1. Create an Azure Function using .NET 8.0 In-Process model.
  2. Add a reference to Polly 8.4.1 from Nuget
  3. Add the following code to Startup class's Configure method:
builder.Services.AddResiliencePipeline("my-key", builder =>
{
    builder.AddTimeout(TimeSpan.FromSeconds(10));
});

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions