Skip to content

Blazor WASM (.NET6) does not allow AAD Authentication when Deployed to Azure Web app #37206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
igalfsg opened this issue Oct 2, 2021 · 13 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components feature-AADIntegration This issue is related to Azure AD integration feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-blazor-wasm-auth investigate
Milestone

Comments

@igalfsg
Copy link

igalfsg commented Oct 2, 2021

Describe the bug

When deployed to Azure Web app with the preview version of .NET 6, the login button stops working and automatically redirects you to YOURSITE/authentication/login-failed. I looked in the logs and browser debug tools and couldn't see an error occurring anywhere. When running the code in localhost there is no problem.

image

To Reproduce

You can repro de issue live by going to https://sshmantest.azurewebsites.net/ and clicking login in the top right.

I have also created a repo with code and it includes the GitHub Action I am using to deploy the code to Azure:
https://github.com/coding-flamingo/BlazorWasmWithAADAuth

The Azure environment is an Azure Web App in a Linux app plan.
App plan:
image

Web App Configuration
image

Exceptions (if any)

No Exceptions were found

Further technical details

  • ASP.NET Core version .NET 6

EDIT: To prove that it works on .net 5 five I moved the .NET 6 app to https://testnet2.azurewebsites.net/ and the working .NET 5 is now in https://sshmantest.azurewebsites.net/

@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-AADIntegration This issue is related to Azure AD integration feature-blazor-wasm-auth labels Oct 2, 2021
@mkArtakMSFT mkArtakMSFT added this to the 6.0.0 milestone Oct 4, 2021
@igalfsg
Copy link
Author

igalfsg commented Oct 14, 2021

Update: updated to the latest .NET Release Candidate and the issue is still occurring

@knight1219
Copy link

What do your App Registries look like?

I had an issue like this and one of the App Registries had a bad set of URLs

@igalfsg
Copy link
Author

igalfsg commented Oct 16, 2021

image
@knight1219 this are my settings for the client side. They should be fine this was a working application before the change to .NET 6

@javiercn javiercn modified the milestones: 6.0.0, Backlog Oct 19, 2021
@ghost
Copy link

ghost commented Oct 19, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@igalfsg
Copy link
Author

igalfsg commented Oct 23, 2021

Update: Tried self-contained still didn't work.

@igalfsg
Copy link
Author

igalfsg commented Oct 26, 2021

@javiercn have you checked with the Webapps team to see if it is an issue they can fix on their side?

@igalfsg
Copy link
Author

igalfsg commented Nov 8, 2021

@javiercn my app is not misconfigured, it literally works on my machine with the same app ID and if I downgrade to .NET5 it works in Azure. As mentioned in my previous comments this happens before going to the STS so it doesn't seem like an Azure AD issue. Seems like an important issue to solve before people try to use it in production. more that it works on debug

@knight1219
Copy link

image

I just tried your demo site and I'm getting this back in the console log. Are you seeing this too?

@igalfsg
Copy link
Author

igalfsg commented Nov 9, 2021

I see those errors when it works in local machine as well so I assumed that it was Blazor looking for an authenticated user before authentication and were safe to ignore
image

@igalfsg
Copy link
Author

igalfsg commented Nov 9, 2021

and if I literally just revert back to .NET 5 it works
image
here is a link to the commit reverting coding-flamingo/BlazorWasmWithAADAuth@f3d16cc
and here are the new app settings:
image

@igalfsg
Copy link
Author

igalfsg commented Nov 9, 2021

To Validate it wasn't a problem with something in my existing Azure web app I even created a new web app that has only been .net 6 and it doesn't work https://testnet2.azurewebsites.net/ for this I created a different branch and updated to .net 6 https://github.com/coding-flamingo/BlazorWasmWithAADAuth/tree/net6 so now I have both running side to side with literally the only change is updating to .net 6

@igalfsg
Copy link
Author

igalfsg commented Nov 19, 2021

Update this can be "Fixed" by adding the following to the Client .csproj file :

<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>

I will be removing my Azure test environments, but will leave this issue open since this is just a workaround until Microsoft fixes the issue...

thanks to u/RoderoDaVinci for finding this fix.

@javiercn
Copy link
Member

We believe this has been addressed in 7.0 as part of #43954.

The fix should be available in RC2.

@javiercn javiercn modified the milestones: Backlog, 7.0-rc2 Sep 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-AADIntegration This issue is related to Azure AD integration feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-blazor-wasm-auth investigate
Projects
None yet
Development

No branches or pull requests

5 participants