Change the source "Branch" in Azure Static Web App
Asked Answered
P

2

7

When setting up an Azure Static WebApp when I chose GitHub as the source provider, the UI provides an option to choose from one of the existing branches. But once the app is created I don't see any option to change the source. Whereas in Azure "App Service", you can disconnect from GitHub and establish the connection again with a different branch.

So, Is it possible to change the source branch in Azure SWA? Azure Static WebApp - Overview screenshot

Prostitution answered 13/5, 2021 at 7:14 Comment(0)
K
7

You might've sorted it out by now, but this confused me as well and it turns out that you set this up on the deployment setup. In my case I'm using DevOps/Pipelines, and on the pipeline (equivalent to Github Actions) you can choose which branch to source from. Then you run the pipeline, and that will automatically change the source in the Static Web app.

Kaden answered 15/6, 2021 at 16:36 Comment(1)
Agreed. Get the workflow yml file from the existing repo and add it to new. Add the secret to the new repo with the same key (secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_...) and the deployment token. Grab the Deployment token from the Azure static web app, Manage deployment token link.Barnebas
F
5

For anyone also struggling with this issue not using Pipelines or anything else; the data shown in the Azure Portal is basically just the values from the .yml file that is generated when you connect the repository to the static web app.

So you can just edit the branch in the corresponding file, e.g.
azure-static-web-apps-xxx.yml

    on:
      push:
        branches:
          - main
      pull_request:
        types: [opened, synchronize, reopened, closed]
        branches:
          - main
[...]

replace main with whatever branch you want to deploy in the future. After pushing these changes the static web app should reflect these changes in the portal.

Fann answered 14/10, 2022 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.