dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.38k stars 350 forks source link

[WebToolsE2E][Aspire] Creating web app with MS Identity auth and aspire checked, F5 failed with 'This service descriptor is keyed. Your service provider may not support keyed services.' #3880

Open v-elenafeng opened 2 months ago

v-elenafeng commented 2 months ago

REGRESSION INFO: Also reproduces on Aspire 8.0 P4 and Aspire 8.0 P5

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.10.0 Preview 5 FB, Preview channel

    • Web workload
    • Includes Aspire 8.0.0-preview.6.24214.1
    • Includes .NET SDK 8.0.300-preview.24203.14 and runtime 8.0.2
    • Apply dotnet-tools feed

REPRO STEPS

  1. New > Project > ASP.NET Core Web App > .NET 8.0 > Microsoft identity platform > Check 'Enlist in .NET Aspire orchestration' > Create
  2. In the popped window, select 'Tenants' to 'Microsoft' > Create a new application > Next > Next > Finish
  3. F5

ACTUAL F5 failed with exception: This service descriptor is keyed. Your service provider may not support keyed services. image

System.InvalidOperationException HResult=0x80131509 Message=This service descriptor is keyed. Your service provider may not support keyed services. Source=Microsoft.Extensions.DependencyInjection.Abstractions StackTrace: at Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ThrowKeyedDescriptor() at Microsoft.Extensions.DependencyInjection.ServiceDescriptor.get_ImplementationType() at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.<>c.b__5_0(ServiceDescriptor s) at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Func2 predicate, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate) at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.AddMicrosoftIdentityWebAppInternal(AuthenticationBuilder builder, Action1 configureMicrosoftIdentityOptions, Action1 configureCookieAuthenticationOptions, String openIdConnectScheme, String cookieScheme, Boolean subscribeToOpenIdConnectMiddlewareDiagnosticsEvents, String displayName) at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.AddMicrosoftIdentityWebAppWithConfiguration(AuthenticationBuilder builder, Action1 configureMicrosoftIdentityOptions, Action1 configureCookieAuthenticationOptions, String openIdConnectScheme, String cookieScheme, Boolean subscribeToOpenIdConnectMiddlewareDiagnosticsEvents, String displayName, IConfigurationSection configurationSection) at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.AddMicrosoftIdentityWebApp(AuthenticationBuilder builder, IConfigurationSection configurationSection, String openIdConnectScheme, String cookieScheme, Boolean subscribeToOpenIdConnectMiddlewareDiagnosticsEvents, String displayName) at Program.

$(String[] args) in C:\Users\v-elenafeng\source\repos\WebApplication9\WebApplication9\Program.cs:line 13

EXPECTED Can run successfully with MSI auth + Aspire enabled.

davidfowl commented 2 months ago

Try updating the identity packages. This is a bug that has been fixed.

v-elenafeng commented 2 months ago

Try updating the identity packages. This is a bug that has been fixed.

Thanks, after updating the identity packages I was able to run successfully. Just wondering when the package version fix in VS will come in? Is there a PR?

davidfowl commented 2 months ago

cc @vijayrkn @BillHiebert @phenning

vijayrkn commented 2 months ago

@deepchoudhery - Can you please get the identity package versions updated in the identity scaffolding for this? This should just be a package update change.

mkArtakMSFT commented 2 months ago

Ping @deepchoudhery in case you didn't see this.

v-elenafeng commented 1 month ago

I'm able to repro this issue with the released VS 17.10.0.

@deepchoudhery ping you again on the packages update for msi to resolve this issue.

image

deepchoudhery commented 1 month ago

Hi, Will look at this issue in my next cycle here, apologies for the delay