Azure Static Web Apps “Failed to deploy the Azure Functions” error—even with minimal hello world API, all best practices followed

Nathaniel Walker 0 Reputation points
2025-06-04T16:33:42.0533333+00:00

We are unable to deploy any backend API (managed functions) to Azure Static Web Apps. Our static frontend always deploys successfully, but every attempt to deploy the backend fails at the “deploy the Azure Functions” step, even with the simplest possible hello world function.

Error:

Deployment Failure Reason: Failed to deploy the Azure Functions.

What we have tried:

Minimal v3 “hello world” function at /api/hello/index.js and /api/hello/function.json, no dependencies, no extensionBundle, basic package.json, and correct host.json.

Confirmed /api structure matches all Microsoft docs (screenshot available).

Set FUNCTIONS_WORKER_RUNTIME=node and all secrets in Azure portal.

Removed all other endpoints—only /api/hello present.

Tested in multiple Azure regions and on new SWA resources.

Locally, everything works with Azure Functions Core Tools.

Frontend-only deploys are always successful.

All builds succeed and Oryx detects Functions Runtime ~4, but deployment fails at the final step (“Failed to deploy the Azure Functions”).

Blocking impact: We are unable to deploy any backend/API for production and this is blocking our internship program.

Request:

Please review logs and confirm if this is a known issue or platform bug with SWA managed Functions.

Advise if there is a workaround or hotfix for unblocking managed Functions deployment.

Attached:

Screenshot of /api structure

Sample code for index.js and function.json

Full Oryx deploy log and error message

Workflow YAML (build/deploy section)

Thank you—this is urgent for our production use.We are unable to deploy any backend API (managed functions) to Azure Static Web Apps. Our static frontend always deploys successfully, but every attempt to deploy the backend fails at the “deploy the Azure Functions” step, even with the simplest possible hello world function.

Error:

Deployment Failure Reason: Failed to deploy the Azure Functions.

What we have tried:

Minimal v3 “hello world” function at /api/hello/index.js and /api/hello/function.json, no dependencies, no extensionBundle, basic package.json, and correct host.json.

Confirmed /api structure matches all Microsoft docs (screenshot available).

Set FUNCTIONS_WORKER_RUNTIME=node and all secrets in Azure portal.

Removed all other endpoints—only /api/hello present.

Tested in multiple Azure regions and on new SWA resources.

Locally, everything works with Azure Functions Core Tools.

Frontend-only deploys are always successful.

All builds succeed and Oryx detects Functions Runtime ~4, but deployment fails at the final step (“Failed to deploy the Azure Functions”).

Blocking impact:
We are unable to deploy any backend/API for production and this is blocking our internship program.

Request:

Please review logs and confirm if this is a known issue or platform bug with SWA managed Functions.

Advise if there is a workaround or hotfix for unblocking managed Functions deployment.

Attached:

Screenshot of /api structure

Sample code for index.js and function.json

Full Oryx deploy log and error message

Workflow YAML (build/deploy section)

Thank you—this is urgent for our production use.

Api folder.png

Oryx Failure.png

yaml.png

yaml2.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Harshitha Veeramalla 1,301 Reputation points Microsoft External Staff Moderator
    2025-06-06T09:24:17.8533333+00:00

    Hi @Nathaniel Walker,

    Even a simple "Hello World" function can fail to deploy if the folder structure doesn't meet the requirements expected by SWA.

    • Make sure you have the below folder structure.

    {EC31D197-EDF0-417B-A81B-DE20F869B34F}

    api - hello folder (with function.json and index.js)
    src - with index.html
    
    • The issue seems to be with your app_location and api_location.
    • If you have dist folder , then set the output_location as dist. As I am not using any dist folder, I have set it as .
    app_location: "src" 
    api_location: "api"  
    output_location: "."
    

    My function.json:

    {
      "bindings": [
        {
          "authLevel": "anonymous",
          "type": "httpTrigger",
          "direction": "in",
          "name": "req",
          "methods": [ "get" ]
        },
        {
          "type": "http",
          "direction": "out",
          "name": "res"
        }
      ]
    }
    

    My Workflow file:

    name: Azure Static Web Apps CI/CD
    on:
      push:
        branches:
          - main
      pull_request:
        types: [opened, synchronize, reopened, closed]
    
        branches:
          - main
    
    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@v3
            with:
              submodules: true
              lfs: false
    
          - 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_WONDERFUL_FOREST_003096B1E }}
              repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
    
              action: "upload"
              app_location: "src" 
              api_location: "api" 
              output_location: "." 
    
      close_pull_request_job:
    
        if: github.event_name == 'pull_request' && github.event.action == 'closed'
    
        runs-on: ubuntu-latest
        name: Close Pull Request Job
    
        steps:
          - name: Close Pull Request
            id: closepullrequest
            uses: Azure/static-web-apps-deploy@v1
    
            with:
    
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_FOREST_003096B1E }}
              action: "close"
    

    Deployment:

    {2BE2553C-9D01-4054-89F1-7BCF26AEB4FA}

    Output:

    User's image

    Hope this helps


    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions, please reply back


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.