Description
Which version of Microsoft Identity Abstractions for dotnet are you using?
Microsoft Identity Abstractions version 5.3.0 via Microsoft.Identity.Web.DownstreamApi version 2.18.1
Is this a new or an existing app?
New app
Repro
Debug an ASP.NET 8.0 application using multiple IDP's and Azure Web PubSub.
// IDP 1
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("EntraExternalID"))
.EnableTokenAcquisitionToCallDownstreamApi()
.AddDownstreamApi("ServiceA", builder.Configuration.GetSection("ServiceA"))
.AddDownstreamApi("ServiceB", builder.Configuration.GetSection("ServiceB"))
.AddInMemoryTokenCaches();
// IDP 2
builder.Services.AddAuthentication().AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("EntraID"), "EntraID");
// Add Web PubSub Service Client
builder.Services.AddWebPubSub(options =>
{
var config = builder.Configuration.GetSection("Config").Get<Configuration<Config>>();
options.ServiceEndpoint = new WebPubSubServiceEndpoint(config.ConnectionString);
}).AddWebPubSubServiceClient<webpubsub>();
// standard init in between e.g. var app = builder.Build();
// Further down map web pubsub event handler
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.MapWebPubSubHub<webpubsub>("/eventhandler/{*path}");
app.Run();
Expected behavior
Error is not observed when debugging on Windows via Visual Studio.
Actual behavior
The call to app.MapWebPubSubHub<webpubsub>("/eventhandler/{*path}");
triggers System.InvalidOperationException: 'Cannot resolve scoped service 'Microsoft.Identity.Abstractions.IDownstreamApi' from root provider.' only when debugging via Visual Studio (latest version - 17.9.6) on Windows. When run in a Linux Container the app runs fine.
Possible solution
N/A