I've created a default Blazor App (Server-side) in Visual Studio 2019 with Azure AD authentication. Running the app locally it authenticates against AAD as expected. However, when deployed to an App Service in Azure the app won't run. The deployment process works fine, Deployment Mode is Self-Contained and App Service is Windows (Linux works the same way). All files and settings are made appropriately, but the below error is displayed when navigating to the site.
This page isn’t working blazorappxxxxxxx.azurewebsites.net is currently unable to handle this request.
HTTP ERROR 500
Disable the authentication code in startup.cs and redeploy, now the app works.
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
The App is registered in AAD and Redirect URIs are set, implicit grant is configured for Access Token and ID Token.