Use preview environment for test in static web app
Published Jul 11 2023 12:53 AM 2,825 Views
Microsoft

Azure Static Web App offers two types of preview environments: branch environment and named environment. Both of these methods offer isolated environments for testing and deploying changes to your Azure Static Web App, allowing you to test and validate changes without affecting the main production environment.

 

Here are the steps to create a preview environment:

 

1. After deploying the production branch to the main site, create a new branch based on the main branch and name it "dev".

Bobi_Bao_0-1689054668304.png

Bobi_Bao_1-1689054702665.png

 

2. Modify your YAML file in the dev branch to include "dev" in the trigger to track any changes in the dev branch.

Bobi_Bao_2-1689054763798.png

 

3. Set "production_branch" to the name of your production branch. This action will ensure the deploy task in the dev branch creates a new preview environment.

Bobi_Bao_3-1689054791241.png

 

4. Save the changes and after deployment, you can see a new environment named 'dev' for the dev branch.

Bobi_Bao_4-1689055120303.png

 

5. If you want to name a preview environment separately (instead of using the branch name), set the "deployment_environment" to the desired name, and it will create a named environment.

Bobi_Bao_5-1689055188600.png

 

Bobi_Bao_6-1689055232551.png

 

The main difference between branch and named environments is that branch environments are created automatically based on the branch name, whereas named environments are custom-named. 

 

Overall, both branch and named environments provide isolated environments for testing and deploying changes to your Azure Static Web App, allowing you to test and validate changes without affecting the main production environment. The choice of environment type typically depends on the specific needs and development process of your project.

Co-Authors
Version history
Last update:
‎Jul 11 2023 12:53 AM
Updated by: