Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: System.InvalidOperationException thrown when registering with AddResiliencePipeline in .NET 8 Isolated Function App #2109

Open
CSharpFiasco opened this issue May 14, 2024 · 1 comment
Labels

Comments

@CSharpFiasco
Copy link

Describe the bug

Seems to be related to the following bug in the .NET 8 runtime: dotnet/runtime#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

@peter-csala
Copy link
Contributor

I tried to reproduce the issue in a console application.

  • When I run the application without the ConfigureFunctionsWorkerDefaults call then it works fine without any exception.
  • When I run the application with the ConfigureFunctionsWorkerDefaults call then I get a different InvalidOperationException:

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants