GitHub to Azure Static Web App - Azure Refusing Token

Nick Brown 0 Reputation points
2025-09-30T06:43:11.35+00:00

I have a Static Web App. In the yml workflow file I have a deployment token designated. That token is listed under Actions > Repository secrets. You can see the name in the output below. Every time I try to run the build I get this output. I turned on debugging for more detail:

Deploy to Azure Static Web Apps

##[debug]Evaluating condition for step: 'Deploy to Azure Static Web Apps'

##[debug]Evaluating: success()

##[debug]Evaluating success:

##[debug]=> true

##[debug]Result: true

##[debug]Starting: Deploy to Azure Static Web Apps

##[debug]Loading inputs

##[debug]Evaluating: secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_OCEAN_06552EA1E

##[debug]Evaluating Index:

##[debug]..Evaluating secrets:

##[debug]..=> Object

##[debug]..Evaluating String:

##[debug]..=> 'AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_OCEAN_06552EA1E'

##[debug]=> '***'

##[debug]Result: '***'

##[debug]Loading env

Run Azure/static-web-apps-deploy@v1

/usr/bin/docker run --name b0d864c6d8af660343ec8a7fec40ea7411c8_7f3a33 --label 89b0d8 --workdir /github/workspace --rm -e "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_ACTION" -e "INPUT_APP_LOCATION" -e "INPUT_SKIP_APP_BUILD" -e "INPUT_APP_ARTIFACT_LOCATION" -e "INPUT_API_LOCATION" -e "INPUT_PRODUCTION_BRANCH" -e "INPUT_API_BUILD_COMMAND" -e "INPUT_OUTPUT_LOCATION" -e "INPUT_APP_BUILD_COMMAND" -e "INPUT_REPO_TOKEN" -e "INPUT_ROUTES_LOCATION" -e "INPUT_CONFIG_FILE_LOCATION" -e "INPUT_SKIP_API_BUILD" -e "INPUT_DEPLOYMENT_ENVIRONMENT" -e "INPUT_IS_STATIC_EXPORT" -e "INPUT_DATA_API_LOCATION" -e "INPUT_GITHUB_ID_TOKEN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_DEBUG" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/site-main-09292025/site-main-09292025":"/github/workspace" 89b0d8:64c6d8af660343ec8a7fec40ea7411c8

DeploymentId: d4681700-15f0-4aed-beda-2152d48d3ee7

Try to validate location at: '/github/workspace'.

App Directory Location: '/' was found.

Try to validate location at: '/github/workspace/swa-db-connections'.

Looking for event info

The content server has rejected the request with: BadRequest

Reason: No matching Static Web App was found or the api key was invalid.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/

If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/

Exiting

##[debug]Docker Action run completed with exit code 1

##[debug]Finishing: Deploy to Azure Static Web Apps

I tried reset the Deployment Token in Azure under the SWA a number of times and updating it in github. Azure refuses to accept it. The debug output shows it sees the token and can read it. Yet Azure insists it doesn't match or is invalid. Of course it won't say which.

I have only one resource that is a SWA. So there is no confusion over whether I'm using the right one.

Anyone have any idea why?

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

1 answer

Sort by: Most helpful
  1. Praneeth Maddali 1,110 Reputation points Microsoft External Staff Moderator
    2025-10-09T04:40:58.51+00:00

    Hi @Nick Brown

    Thank you for reaching regarding issue deployment token errors The “Invalid API key” error usually indicates that the deployment token does not match the Static Web App environment. This can happen if the token was regenerated, is linked to a different resource, or is being used in the wrong context.

    1. Reset the Deployment Token
    • Azure Portal: Navigate to your Static Web App, select Manage deployment token, click Reset, and carefully copy the new token without any spaces or line breaks.
    • GitHub: Go to Settings, then Secrets and variables, select Actions, and update AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_OCEAN_06552EA1E with the new token.
    1. Verify Workflow File
    • Open .github/workflows/*.yml and confirm: yaml
        azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_OCEAN_06552EA1E }}
        app_location: "/"
        api_location: "swa-db-connections"
        runs-on: ubuntu-latest
      
    • In Azure Portal > Deployment Center, make sure that the appropriate repository and branch are connected.
    1. Check Resource State
    • In Azure CLI, run:
        az staticwebapp show --name <your-swa-name> --resource-group <your-group>
      
    • If state is null or failed, reset token
        az staticwebapp secrets reset-api-key --name <your-swa-name> --resource-group <your-group>
      

    4.Reconnect GitHub if necessary:

    • In the Azure Portal, go to Deployment Center, select Disconnect, and then reconnect your GitHub repository.
    • Check the new workflow file to confirm that app_location and api_location are correct, commit the changes, and update the secret.

    5.Test Locally (optional)

    • Install SWA CLI: npm install -g @azure/static-web-apps-cli
    • Set SWA_CLI_DEPLOYMENT_TOKEN=<new-token> and run:
        swa deploy --env production
        
      

    Reference:

    https://free.blessedness.top/en-us/azure/static-web-apps/deployment-token-management

    https://free.blessedness.top/en-us/azure/static-web-apps/build-configuration?tabs=identity&pivots=github-actions

    https://free.blessedness.top/en-us/azure/static-web-apps/faq

    Kindly let us know if the above helps or you need further assistance on this issue.

     

    Please "upvote" if the information helped you. This will help us and others in the community as well.


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.