1

I want to publish my VS solution to Azure static web app, I'm using the template that has Blazor WASM, a .Net Core API and Authentication with Identity inside the API.

It works fine on my local machine but after being published as an Azure static web app, it runs but remains authorizing...

The error is:

Could not load settings from '_configuration'

This is the browser console:

enter image description here

Client - program.cs:

public class Program
{
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");

            builder.Services.AddHttpClient("x.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
                .AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();

            // Supply HttpClient instances that include access tokens when making requests to the server project
            builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("x.ServerAPI"));

            builder.Services.AddApiAuthorization();

            await builder.Build().RunAsync();
        }
}

Need help making this work...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MarchalPT
  • 1,268
  • 9
  • 28
  • Hi, I have been struggling with the exact same problem for the past week now myself. I have even tried adding a .pfx copy of my certificate in the wwwroot and include the pfx key in the appsettings.json file – DataWrangler1980 Apr 25 '21 at 09:32
  • @Kommando1980 I have found the solution to the problem already, just follow the link bellow. – MarchalPT Apr 27 '21 at 08:40
  • Thank you for the message. I am still not getting this to work. Not sure what to try next :( – DataWrangler1980 Apr 27 '21 at 16:32

1 Answers1

0

What was happening was the lack of a certificate in my case, I followed this answear and it worked: https://stackoverflow.com/a/66448397/12824729

I dont know if it is possible to work without a certificate when we have to do authentications, tried making the Key type development but wont authenticate..

MarchalPT
  • 1,268
  • 9
  • 28
  • Hi, I do have a pfx and specified the key which works fine locally, but not after hosting to my domain provider?https://stackoverflow.com/questions/67425353/authenticationservice-js1-get-https-mydomainname-co-za-configuration-project – DataWrangler1980 May 06 '21 at 20:43
  • Your certificate CN name must coincide with your domain and the store should be currentuser/my instead localmachine – MarchalPT May 08 '21 at 08:39
  • Hi, it is the same certificate - i obtained it from my service provider and they confirmed it is the same ssl that was converted to pfx. it is the same one used on the domain – DataWrangler1980 May 08 '21 at 09:15
  • 1
    Hi, in my case the problem was resolved by my hosting provider. They advised that the application pool must be granted full access to the root folder (the folder in which wwwroot folder exists). After doing this my website is now working. – DataWrangler1980 May 17 '21 at 14:25