Azure Static Web App returns 404

Zdenek 11 Reputation points
2022-04-06T19:13:49.093+00:00

I created Azure Static Web App back in 2020 when static apps were in preview. Since then my static site worked fine until today when I found out it returns 404. I can't even tell for how long site was broken (not really checking it too often). My site consist of single hand-made index.html, css and couple of other files.

I tried to redeploy, GitHub actions doesn't reveal anything suspicious:

2022-04-06T14:33:11.4765237Z App Directory Location: '/public' was found.  
2022-04-06T14:33:11.4765914Z No Api directory specified. Azure Functions will not be created.  
2022-04-06T14:33:11.4766325Z Looking for event info  
2022-04-06T14:33:12.5658043Z Starting to build app with Oryx  
2022-04-06T14:33:12.5667037Z Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx  
2022-04-06T14:33:12.5667637Z ---Oryx build logs---  
2022-04-06T14:33:13.1445987Z Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx  
2022-04-06T14:33:13.1451757Z You can report issues at https://github.com/Microsoft/Oryx/issues  
2022-04-06T14:33:13.1460436Z Oryx Version: 0.2.20220323.2, Commit: ..., ReleaseTagName: 20220323.2  
2022-04-06T14:33:13.1471542Z Build Operation ID: ...  
2022-04-06T14:33:13.1476310Z Repository Commit : ...  
2022-04-06T14:33:13.1715495Z Detecting platforms...  
2022-04-06T14:33:13.2014391Z Could not detect any platform in the source directory.  
2022-04-06T14:33:13.2299959Z Error: Could not detect the language from repo.  
2022-04-06T14:33:15.2343958Z ---End of Oryx build logs---  
2022-04-06T14:33:15.2345213Z Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.  
2022-04-06T14:33:15.2391132Z Finished building app with Oryx  
2022-04-06T14:33:15.2880586Z Found and validated 'routes.json' within build artifacts folder.  
2022-04-06T14:33:15.2991625Z Either no Api directory was specified, or the specified directory was not found. Azure Functions will not be created.  
2022-04-06T14:33:15.5923587Z Zipping App Artifacts  
2022-04-06T14:33:15.6138575Z Done Zipping App Artifacts  
2022-04-06T14:33:15.6139069Z Uploading build artifacts.  
2022-04-06T14:33:17.0394074Z Finished Upload. Polling on deployment.  
2022-04-06T14:33:19.7194561Z Status: InProgress. Time: 2.6797575(s)  
2022-04-06T14:33:34.9339064Z Status: Succeeded. Time: 17.8915461(s)  
2022-04-06T14:33:34.9339676Z Deployment Complete :)  
2022-04-06T14:33:34.9341608Z Visit your site at: https://yadayadayada.azurestaticapps.net  

(for version with staticwebapp.config.json I'm of course getting output regarding detection of new config and not using routes.json; at the beginning, I was using preview version of Azure/static-web-apps-deploy but now having v1)

My current routes.json looks like this:

{  
  "routes": [  
  {  
    "route": "/*",  
    "serve": "/index.html",  
    "statusCode": 200  
  }],  
  "defaultHeaders": {  
    "content-security-policy": "default-src https: 'unsafe-eval' 'unsafe-inline' cdn.jsdelivr.net *.mapy.cz",  
    "x-frame-options": "deny",  
    "feature-policy": "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'",  
    "permissions-policy": "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"  
  }  
}  

I just discovered routes.json is deprecated and staticwebapp.config.json should be used (https://learn.microsoft.com/en-us/azure/static-web-apps/configuration) - so I created:

{  
  "routes": [  
    {  
      "route": "/example",  
      "rewrite": "/example.html"  
    }  
  ],  
  "navigationFallback": {  
    "rewrite": "index.html",  
    "exclude": [".well-known/*", "css/*"]  
  },  
  "globalHeaders": {  
    "Content-Security-Policy": "default-src https: 'unsafe-eval' 'unsafe-inline' cdn.jsdelivr.net *.mapy.cz",  
    "Feature-Policy": "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'",  
    "Permissions-Policy": "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()",  
    "X-Frame-Options": "deny"  
  }  
}  

... but even with this setup, it still doesn't work and I'm getting 404.

Structure of my repository is following:

/  
├─ .github/  
│  ├─ azure-static...yml  
├─ public/  
│  ├─ .well-known/  
│  │  ├─ security.txt  
│  ├─ css/  
│  │  ├─ style.css  
│  ├─ index.html  
│  ├─ robots.txt  
│  ├─ routes.json  
│  ├─ staticwebapp.config.json  
├─ .gitignore  

My GitHub actions job looks like this - notice app_location to be set to "public" - matching public directory name where my static content is:

jobs:  
  build_and_deploy_job:  
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')  
    runs-on: ubuntu-latest  
    name: Build and Deploy Job  
    steps:  
      - uses: actions/checkout@v2  
        with:  
          submodules: true  
      - name: Build And Deploy  
        id: builddeploy  
        uses: Azure/static-web-apps-deploy@v1  
        with:  
          azure_static_web_apps_api_token: ${ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_YADA_YADA_YADA }  
          repo_token: ${ secrets.GITHUB_TOKEN } # Used for Github integrations (i.e. PR comments)  
          action: "upload"  
          ###### Repository/Build Configurations ######  
          app_location: "public"  
          ###### End of Repository/Build Configurations ######  

Could anyone help me figure out what am I doing wrong, what do I miss?

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
426 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
4,906 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Zdenek 11 Reputation points
    2023-01-12T14:27:03.77+00:00

    I wasn't able to solve it, technical support was clueless. The easiest option is to just ditch your old deployment and start with new one.

    2 people found this answer helpful.
    0 comments No comments