Reputation: 4249
I've created a Static Web App in Azure Portal, to host my Angular app. The creation wizard automatically generated a pipeline in my Azure Repo. If I go to Azure DevOps, I can see the pipeline's YAML which looks like this:
name: Azure Static Web Apps CI/CD
pr:
branches:
include:
- master
trigger:
branches:
include:
- master
jobs:
- job: build_and_deploy_job
displayName: Build and Deploy Job
condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
pool:
vmImage: ubuntu-latest
variables:
- group: Azure-Static-Web-Apps-purple-bush-094d6d303-variable-group
steps:
- checkout: self
submodules: true
- task: AzureStaticWebApp@0
inputs:
azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_PURPLE_BUSH_094D6D303)
###### 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 source code path - optional
output_location: "dist/propworx-portal" # Built app content directory - optional
###### End of Repository/Build Configurations ######
So this builds and publishes the master branch of my repo to the production environment.
Now I'm really a back-end developer, and have only used Azure Web Apps before. It's my first time using Azure Static Web Apps. In Azure Web Apps, I would create deployment slots, and have my staging branch deployed to my staging slot. After testing, I would then swap the staging and production slots.
I'm struggling to figure out how to reproduce something, at least similar, with Azure Static Web Apps. There is no "Deployment Slots" section on Azure Portal. If I understand correctly, slots get created automatically, based on my repository branches? (And the pipelines I create for them?). So, I think I need to create a new pipeline to build and publish my staging branch, to a staging slot. But, when I try to do that (by creating a new pipeline and copy-and-pasting the YAML of the master pipeline) and changing the "branch" in the YAML from "master" to "staging", and run the pipeline manually, it still deploys to the same URL as the other master pipeline. I would need it to deploy to a different URL (i.e. to a different slot). Also, the pipeline doensn't run automatically when I push my commit to the staging branch, the way the master pipeline runs when I push a commit to the master branch.
Any guidance/hints/pointers would be really appreciated! Thank you.
Upvotes: 3
Views: 3680
Reputation: 1175
Static Web Apps don't have deployment slots, but something called preview environments. You can control to which environment the deployment task deploys into with the deployment_environment input.
The documentation can be found from here. I haven't really used environment branches that much, but I'd guess the closest equivalent to deploying from a staging branch to staging slot, would be to to set the deployment_environment to whatever branch you would deploy into production slot with web apps, have the pipeline trigger from both that branch and the staging branch.
Upvotes: 4