static webapp deployment fails in prod but exact same code works in develop environment

De Bondt, Hannes (Mechelen) 5 Reputation points
2024-02-26T09:25:49.02+00:00

I have the code for a static webapp in a github repository. The code is being deployed via github actions.

When I deploy to a development environment using the github actions from the development branch, this works as expected.

When I deploy from the master branch, with

jobs:
  build_and_deploy_prod_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'workflow_dispatch'
    runs-on: [self-hosted,docker]
    name: Build and Deploy Prod Job
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Build And Deploy Prod
        id: builddeployprod
        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 }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          production_branch: "master"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/" # App source code path
          api_location: "/api" # Api source code path - optional
          output_location: "build" # Built app content directory - optional
          ###### End of Repository/Build Configurations ###### 

in the workflow file, I always get the error

Deployment Failed :(
Deployment Failure Reason: Failed to deploy the Azure Functions.

There are no differences between the 2 repositories, so I guess there must be something static-web-app related to the failure and not code related.

Thanks for helping me troubleshoot this issue.

Kind regards

Hannes

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
895 questions
{count} votes

2 answers

Sort by: Most helpful
  1. De Bondt, Hannes (Mechelen) 5 Reputation points
    2024-02-28T07:55:34.32+00:00

    I found the issue. When deploying the static webapp a few months ago, before configuration was in Environment Variables, there was a FUNCTIONS_WORKER_RUNTIME = node. This was migrated to the environment variables.

    When removing this variable and moving it inside the staticwebapp.config.json, deployment worked as expected.

    I hope to have helped at least 1 person with finding the answer on my own question

    1 person found this answer helpful.
    0 comments No comments

  2. SnehaAgrawal-MSFT 21,266 Reputation points
    2024-02-29T09:32:51.1+00:00

    @De Bondt, Hannes (Mechelen) Glad that you were able to resolve your issue and I appreciate your effort in sharing the solution. Your contribution will undoubtedly assist others facing similar challenges.

    As the Microsoft Q&A community follows a policy where the question author cannot accept their own answer

    I've reposted your solution.  Feel free to consider "Accepting" the answer if you find it suitable.

    Problem: The issue is that deploying from the development branch via GitHub Actions works for the development environment, but for master branch error- Deployment Failed :( Deployment Failure Reason: Failed to deploy the Azure Functions.

    Solution: "When deploying the static webapp a few months ago, before configuration was in Environment Variables, there was a FUNCTIONS_WORKER_RUNTIME = node. This was migrated to the environment variables. When removing this variable and moving it inside the staticwebapp.config.json, deployment worked as expected."

    Thanks again.

    0 comments No comments

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.