How to Deploy a Web App With the AzureWebApp Task in Azure Pipelines
The AzureWebApp@1 task pushes a package or zip to an App Service web app using the service connection you name.
Build and zip your app, then use AzureWebApp@1 with azureSubscription, appName, and package. The task uploads and swaps the package into the running app.
Steps
- Produce a deployable package or zip in an earlier step.
- Add
AzureWebApp@1withazureSubscriptionandappName. - Set
packageto the zip or folder to deploy.
Pipeline
azure-pipelines.yml
steps:
- script: |
npm ci && npm run build
zip -r $(Build.ArtifactStagingDirectory)/app.zip dist
displayName: Package
- task: AzureWebApp@1
inputs:
azureSubscription: 'prod-arm-connection'
appName: checkout-api
package: $(Build.ArtifactStagingDirectory)/app.zip
displayName: Deploy to App ServiceGotchas
- Pair this task with a deployment job and environment to record deployment history.
- Use
deployToSlotOrASEandslotNameto deploy to a staging slot, then swap. - The service connection identity needs Contributor on the target web app.
Related guides
How to Run the Azure CLI With a Service Connection in Azure PipelinesRun authenticated az commands in Azure Pipelines with the AzureCLI@2 task, passing an azureSubscription servi…
How to Use a Deployment Job With an Environment in Azure PipelinesTrack and gate releases in Azure Pipelines with a deployment job that targets a named environment, recording…