Azure Static Web App returns 404 after successful deployment

AISC 0 Reputation points
2026-11-30T10:17:32.2233333+00:00
  • GitHub Actions verified that out/index.html and out/dashboard/index.html existed and were nonempty before upload.
  • Azure reported Deployment Complete, and the environment for branch dev shows Ready.
  • The Azure-provided URL still returns 404 for /, /index.html, and /dashboard/, even after a redeploy.
Azure Static Web Apps
Azure Static Web Apps

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


1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-30T10:18:37.6733333+00:00

    If out is built before the deployment action, deploy that directory directly with app_location: "out", skip_app_build: true, and an empty output_location, then test the URL shown specifically for the dev environment rather than the production hostname.

    Correct the prebuilt-artifact deployment

    In .github/workflows/azure-static-web-apps-*.yml, configure the upload step as follows:

    - name: Deploy prebuilt site
      uses: Azure/static-web-apps-deploy@v1
      with:
        azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        action: upload
        app_location: out
        api_location: ""
        output_location: ""
        skip_app_build: true
        production_branch: main
    

    For a prebuilt deployment, app_location is the directory containing the files to upload, while output_location must be empty. Microsoft also specifies that staticwebapp.config.json, when used, must be copied into that output directory.^1^

    Do not combine either of these configurations:

    app_location: "/"
    output_location: "out"
    skip_app_build: true
    

    or:

    app_location: "out"
    output_location: "out"
    

    With skip_app_build: true, Azure treats app_location itself as the build output location. In the normal build mode, by contrast, output_location is interpreted relative to app_location.^1^

    Commit this workflow change and inspect GitHub repository → Actions → workflow run → Build and Deploy Job → Build And Deploy. The deployment log is the authoritative place to see which app directory was packaged.^2^

    Open the correct dev URL

    If main is configured as production_branch, a push from dev is deployed as a branch preview environment—not to the default production hostname. Its URL has a form similar to:

    <DEFAULT_HOST_NAME>-dev.<LOCATION>.azurestaticapps.net
    

    Open Azure portal → Static Web App → Environments → dev and use the URL displayed for that row. Branch environments have separate stable URLs containing the branch name.^3^

    Also check that the workflow contains both:

    on:
      push:
        branches:
          - main
          - dev
    

    and:

    production_branch: main
    

    The production branch is served through the production hostname; other configured branches are served through preview hostnames. Custom domains do not work with preview environments.^4^

    If dev is intended to be production, set:

    production_branch: dev
    

    Then a dev deployment targets the production environment and default hostname. Do not set deployment_environment unless a named preview environment is intentional; that setting explicitly directs deployments to a separate named environment.^5^

    If the corrected environment URL still returns 404

    Because /index.html itself returns 404, a client-side navigation fallback is not the primary fix. A fallback only addresses browser requests for routes that do not exist as deployed assets; it does not make an absent deployed /index.html appear.^6^

    Run these checks next:

    1. In the deployment log, verify that the action identifies out as the app directory and does not run a second Oryx frontend build.
    2. Ensure out/staticwebapp.config.json exists if configuration is required.
    3. In Azure portal → Static Web App → Environments, verify that the hostname being tested belongs to the same dev environment updated by the latest workflow run.
    4. Open Diagnose and solve problems for the Static Web App and review the diagnostic report.^2^
    5. If the corrected artifact configuration still produces a branded 404 for /index.html on the exact environment URL, open an Azure support request and include the workflow run URL, deployment ID, environment name, hostname, and UTC request time. At that point the symptom is consistent with content not being attached to the environment despite a completed deployment, rather than an application route issue.

    References

    1. Build configuration for Azure Static Web Apps (github-actions)
    2. Troubleshooting deployment and runtime errors
    3. Create branch preview environments in Azure Static Web Apps
    4. Preview environments in Azure Static Web Apps
    5. Create named preview environments in Azure Static Web Apps
    6. Azure Static Web Apps Frequently Asked Questions
    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.