How can I change the appsettings on the preview environemnts that are generated by the Azure Static Web Apps CI/CD Github Action for each pull request?
I can go to the portal, navigate to the generated environment and change its appsettings. Doing this manually for each new pull request is error prone and will become tedious really fast.
I couldn't find any reference to this in the Build Configuration For Azure Static Webapps docs so I'm assuming it can't be configured that way. I also couldn't find any reference to SWA environments in the CLI docs. I looked into deployment environments but it looks like this is some other kind of deployment environment as it keeps mentioning devcenter.
In Azure Portal
, While Creating Static Web App, after providing the GitHub Repo
and Branch
details, we will get an option to preview the Workflow file.
I can go to the portal, navigate to the generated environment and change its appsettings
Yes, In Configuration Section we have an option to add the App settings
. But it is a manual work, which is not advised to follow.
Once we click on Review + create
and create the Static Web App, a new folder with name .github/workflows
will be created in the GitHub Repository
.
It contains the same workflow file (preview file
), which we saw while creating the Static WebApp
in Azure Portal.
We can edit the Workflow manually.
To update the appsettings/configurations
in the workflow, we can specify the steps in the existing workflow
file.
We can use either Powershell/Azure CLI
commands to update the Appsettings
.
az staticwebapp appsettings set --name YourStaticWebAppname --setting-names "message=HelloEveryOne"
***Sample code for Updating App settings: ***
Before Build and deploy
step in Workflow, add the below steps.
- name: Build And Deploy
- run : Your Update appsettings Script
To edit the Workflow file, click on the .github/workflow
=> .yml
file
References taken from MSDoc 1 and 2.
As per the discussion in GitHub, adding appsettings to the preview environment is not currently supported in the default Azure Static Web Apps CI/CD
.