IDX20803: Unable to obtain configuration from: 'System.String' Azure B2C

Eskil Lundgren 1 Reputation point
2021-11-02T13:40:17.663+00:00

Trying to connect to my Azure B2C to have clients access an app. With very little luck. I'm new on Azure so I might have made some very basic error.

The error "IDX20803: Unable to obtain configuration from: 'System.String'" I get when I click the "Login" link in a blazor server app. I'm just trying to get this to work in a basic app, then I'll transfer the bits that deals with auth to my real app.

Startup.cs:
public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services) {
    services.AddRazorPages();
    services.AddServerSideBlazor();
    services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();

    services.AddSingleton<WeatherForecastService>();
    services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAdB2C"));
    services.AddControllersWithViews()
    .AddMicrosoftIdentityUI();
    services.AddAuthorization(options =>
    {

    });
services.AddServerSideBlazor()
.AddMicrosoftIdentityConsentHandler();
    }
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
    if(env.IsDevelopment()) {
    app.UseDeveloperExceptionPage();

    } else {
    app.UseExceptionHandler("/Error");
    app.UseHsts();
    }
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseEndpoints(endpoints => {
    endpoints.MapBlazorHub();
    endpoints.MapFallbackToPage("/_Host");
    endpoints.MapControllers();
    });
    }

appsettings.json

"AzureAdB2C": {
"Instance": "https://*****.b2clogin.com/",
"ClientId": "11111-965c-40c5-8dda-9315638fbda3",
"CallbackPath": "/signin-oidc",
"Domain": "*****.b2clogin.com",
"SignedOutCallbackPath": "/signout-callback-oidc",
"SignUpSignInPolicyId": "B2C_1_SignupAndSignin",
"ClientSecret": "11111-0f01-49f7-827a-bff6522bc1e6"
}

These are the redirect URL:s from the app:

https://localhost:44340/
https://localhost:44340/MicrosoftIdentity/Account/SignIn
https://*****.azurewebsites.net/MicrosoftIdentity/Account/SignIn
https://*****.azurewebsites.net/

Anyone know what I'm doing wrong?

Cheers!

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
795 questions
Azure Active Directory External Identities
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
12,721 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 20,596 Reputation points Microsoft Employee
    2021-11-03T21:59:04.997+00:00

    Hi @Eskil Lundgren ,

    I'm not sure if you included the full values in the settings that you shared, but your Domain needs to be set to your Azure AD B2C domain in the appsettings.json. So it should be set to <tenant-name>.onmicrosoft.com.

    According to the b2c Instance example in the appsettings.json, I believe your value needs to be set to https://<tenant-name>.b2clogin.com/

    Let me know if this helps at all.

    See also:

    How to fix IDX20803
    How to investigate IDX20803: Unable to obtain configuration from: 'System.String'