[Bug]: System.InvalidOperationException thrown when registering with AddResiliencePipeline in .NET 8 Isolated Function App
Describe the bug
Seems to be related to the following bug in the .NET 8 runtime: https://github.com/dotnet/runtime/issues/95789.
Expected behavior
I would expect the function app to register the single event hub trigger
Actual behavior
Exception thrown: 'System.InvalidOperationException' in Microsoft.Extensions.DependencyInjection.Abstractions.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Extensions.DependencyInjection.Abstractions.dll
This service descriptor is keyed. Your service provider may not support keyed services.
Steps to reproduce
using Microsoft.Extensions.Hosting;
using Polly;
using Polly.Retry;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((builder, services) =>
{
services.AddResiliencePipeline("my-pipeline", (resiliencePipeLineBuilder, context) =>
{
resiliencePipeLineBuilder.InstanceName = "my-pipeline";
resiliencePipeLineBuilder.AddRetry(new RetryStrategyOptions());
});
})
.Build();
host.Run();
Exception(s) (if any)
Microsoft.Extensions.DependencyInjection.Abstractions.dll!Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ThrowKeyedDescriptor() Unknown
Microsoft.Extensions.DependencyInjection.Abstractions.dll!Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ImplementationInstance.get() Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.Populate() Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CallSiteFactory(System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> descriptors) Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceProvider.ServiceProvider(System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> serviceDescriptors, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) Unknown
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection containerBuilder) Unknown
Microsoft.Extensions.Hosting.dll!Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter<Microsoft.Extensions.DependencyInjection.IServiceCollection>.CreateServiceProvider(object containerBuilder) Unknown
Microsoft.Extensions.Hosting.dll!Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() Unknown
Microsoft.Extensions.Hosting.dll!Microsoft.Extensions.Hosting.HostBuilder.Build() Unknown
> MyEvents.dll!Program.<Main>$(string[] args) Line 5 C#
Polly version
8.4.0
.NET Version
8.0.204
Anything else?
I've based my code around the following guidelines: https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#start-up-and-configuration. Let me know if you'd like me to spin up a simplified project
I tried to reproduce the issue in a console application.
- When I run the application without the
ConfigureFunctionsWorkerDefaultscall then it works fine without any exception. - When I run the application with the
ConfigureFunctionsWorkerDefaultscall then I get a differentInvalidOperationException:
System.InvalidOperationException: The gRPC channel URI 'http://:' could not be parsed.
I don't see anything which is Polly related in either StackTraces.
Could you please run your code but now without the AddResiliencePipeline call?
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
This issue was closed because it has been inactive for 14 days since being marked as stale.