An error occurs when Blazor WASM is routed through Azure Front Door

takeolexus 180 Reputation points
2023-05-29T08:07:58.6866667+00:00

I have implemented Blazor WASM app with AAD refer to the URL below.

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory?view=aspnetcore-7.0

This worked fine, but An error occured when I created a Azure Front Door and I requested from it.

An error massage is below.

There was an error trying to log you in: ''

When I click 'Log in', I get the following error.

There was an error trying to log you in: 'window.crypto.randomUUID is not a function.
(In 'winod.crypto.randomUUID()','window.crypto.randomUUID' i undefined)'

Do I need to change Azure Front Door or any settings?

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
858 questions
Developer technologies | .NET | Blazor
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. Akshay-MSFT 17,956 Reputation points Microsoft Employee Moderator
    2023-05-30T05:49:17.2566667+00:00

    @Anonymous

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    Blazor WASM app with AAD throws error when user tries to hit login after creating a front door

    There was an error trying to log you in: ''

    When click 'Log in', I get the following error.

    There was an error trying to log you in: 'window.crypto.randomUUID is not a function.

    (In 'winod.crypto.randomUUID()','window.crypto.randomUUID' i undefined)'

    Solution:

    Login mode value to be set "redirect". The framework defaults to pop-up login mode and falls back to redirect login mode if a pop-up can't be opened. Configure MSAL to use redirect login mode by setting the LoginMode property of MsalProviderOptions to redirect:

    The default setting is popup, and the string value isn't case-sensitive.

    builder.Services.AddMsalAuthentication(options =>
    {
        ...
        options.ProviderOptions.LoginMode = "redirect";
    });
    

    Thanks,

    Akshay Kaushik

    Please "Accept the answer" (Yes), and share your feedback if the suggestion answers you’re your query. This will help us and others in the community as well.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.