Azure Static Web Apps Free: built-in Microsoft authentication callback returns HTTP 401

Hammad Ali 0 Reputation points
2026-10-12T10:40:48.7033333+00:00

We are verifying owner-only access for an isolated development placeholder on Azure Static Web Apps Free. The placeholder contains no customer data, API keys or application logic. Built-in Microsoft Entra authentication is used; no custom authentication registration or custom provider is configured.

Observed failure:

  • The owner completed individual Microsoft consent; organization-wide consent was not granted.
  • The built-in Microsoft authentication callback returns HTTP 401.
  • An account-specific AAD invitation for the owner-only custom role also ends at callback HTTP 401.
  • The accepted-user inventory remains empty, so owner access and authenticated non-owner denial are not yet verified.
  • The same failure was observed in two browser environments.

Sanitized configuration:

  • Free hosting plan. Supported Static Web Apps CLI deployment.
  • All application routes require one custom owner role. The GitHub login provider is blocked.
  • No navigation fallback. Protected page, static asset and direct-route GET/HEAD requests anonymously return HTTP 401 with no-store.
  • No client-side-only access guard is being used. Full application deployment is held.

Separate diagnostic limitation:

  • A read-only Microsoft Graph auditLogs/signIns request returned HTTP 403, error Authentication_RequestFromNonPremiumTenantOrB2CTenant, stating that the tenant does not have a premium license.
  • We do not assume this diagnostic-license limitation causes the Static Web Apps authentication failure.

Troubleshooting completed:

  • Verified successful placeholder deployment and existing company-account Azure administration access.
  • Verified anonymous route/asset rejection and no navigation fallback.
  • Tested individual consent and owner-role invitation without relaxing authorization.
  • Attempted official Azure portal support routing; it stalled during automated analysis without creating a case.
  • Further identical consent attempts have been stopped.

Please clarify:

  1. Is built-in Microsoft authentication with an invited custom owner role supported on Free without an Entra premium license?
  2. How can we diagnose a provider callback HTTP 401 separately from an application-role HTTP 401?
  3. Could the selected built-in identity configuration or identity backend cause this failure, and what supported correction is recommended?
  4. Which diagnostics are available without premium licensing?
  5. What supported owner-only alternative is available without weakening direct-route and static-asset protection?

No credentials, tokens, account identifiers, private resource URLs, tenant/subscription identifiers, customer information, internal source code or sensitive logs are included.

Azure Static Web Apps
Azure Static Web Apps

An Azure service that provides streamlined full-stack web app development.

0 comments No comments

1 answer

Sort by: Newest
  1. AI answer

    2026-10-12T10:41:14.12+00:00
    1. Yes. The documented authentication and authorization features are available in all Azure Static Web Apps plans. Built-in authentication supports Microsoft Entra ID, and custom roles are supported through route rules plus role assignment mechanisms such as invitations. The provided documentation does not state that a Microsoft Entra premium license is required for Static Web Apps built-in authentication.
    2. The supported way to separate provider-authentication behavior from app authorization is to distinguish these endpoints and outcomes:
      1. Provider sign-in uses /.auth/login/aad for Microsoft Entra ID.
      2. The authentication callback endpoint for Entra ID is https://<YOUR_SITE>/.auth/login/aad/callback.
      3. App authorization is enforced by route rules in staticwebapp.config.json, such as allowedRoles.
      A callback 401 occurs in the authentication flow before route authorization to protected app content. A route-level 401 occurs when a request matches a protected route and the signed-in user does not have one of the required roles. For owner-only access, a route like this requires the assigned custom role:
         {
           "route": "/admin*",
           "allowedRoles": ["administrator"]
         }
      
      If the goal is to verify authentication separately from the custom owner role, the documented supported configuration is to temporarily protect a route with the built-in authenticated role instead of the custom role. That confirms sign-in independently of invitation-based role assignment.
    3. Yes. The selected identity configuration can cause this if the app relies on the preconfigured Microsoft Entra provider while expecting tenant restriction. The preconfigured Microsoft Entra ID provider allows any Microsoft account to sign in. To restrict sign-in to a specific Microsoft Entra tenant, the documented supported correction is to configure a custom Microsoft Entra ID provider. For custom Entra configuration, the callback uses the same documented callback pattern and aad as the provider name placeholder for Entra ID. Also, if a custom provider is registered, all preconfigured providers are disabled. Since no custom provider is configured in this scenario, built-in providers remain active unless explicitly blocked by route rules. The context also contains a Microsoft Q&A case showing a known issue where some newer deployments were routed to an unhealthy identity backend and authentication failed with 401 on the callback, while later deployment to a healthy backend succeeded. That indicates identity backend behavior can also cause callback 401 independently of app route authorization.
    4. Without premium licensing, the supported diagnostics in the provided material are:
      1. Validate the auth flow endpoints directly:
        • Login: /.auth/login/aad
        • User details: /.auth/me
        • Logout: /.auth/logout
        • Purge user details: /.auth/purge/aad
      2. Validate route behavior through staticwebapp.config.json rules and responseOverrides.
      3. Reproduce locally with the Static Web Apps CLI emulator using npx swa start, which provides a local sign-in page and role emulation.
      The provided material does not document additional Entra sign-in log diagnostics for non-premium tenants.
    5. A supported owner-only alternative without weakening direct-route and static-asset protection is:
      1. Keep route protection in staticwebapp.config.json using allowedRoles so protection is enforced server-side for HTTP requests.
      2. Use a custom Microsoft Entra ID provider if sign-in must be restricted to a specific tenant.
      3. Assign the owner-only custom role through the documented invitations system or programmatically at sign-in with an API function.
      For whole-app protection, the documented pattern is:
         {
           "routes": [
             {
               "route": "/*",
               "allowedRoles": ["authenticated"]
             }
           ],
           "responseOverrides": {
             "401": {
               "statusCode": 302,
               "redirect": "/.auth/login/aad"
             }
           }
         }
      
      Then replace authenticated with the owner-only custom role after authentication is confirmed. This preserves server-side protection of direct routes and static assets. The documentation also warns that routing rules secure HTTP requests served by Static Web Apps, while sensitive data for client-side routes should be protected through APIs that validate identity.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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