Introduction
Manually deploying apps to Azure can get repetitive — especially when your team updates code often.
That’s where Azure Pipelines comes in. It helps you automate your build and deployment using a simple YAML file.
With every new code push, your app can automatically:
Build and package itself
Test for errors
Deploy to Azure App Service or Azure Function App
Let’s go step-by-step to create one such automated deployment pipeline.
What You Need Before Starting
An Azure account with an existing App Service or Function App.
Source code stored in a Git repo (like GitHub or Azure Repos).
An Azure DevOps project (you can create one for free at dev.azure.com).
A Service Connection between Azure DevOps and your Azure Subscription — this lets the pipeline deploy to your resources.
Step 1: Create a YAML Pipeline
In your code repository, create a file named azure-pipelines.yml at the root.
Here’s a simple example for a .NET web app:
trigger:
- main # run the pipeline whenever code is pushed to 'main'
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
# Step 1: Build and publish the project
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
# Step 2: Deploy to Azure App Service
- task: AzureWebApp@1
inputs:
azureSubscription: '<your-service-connection-name>'
appName: '<your-app-service-name>'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'Step 2: Understanding the YAML File
Let’s break it down in plain English:
trigger→ Tells the pipeline when to run (here, whenever you push to the main branch).pool→ Defines which virtual machine image to use for building.DotNetCoreCLI@2task → Builds your app and packages it into a folder.AzureWebApp@1task → Uploads your package to the Azure App Service and deploys it.
Step 3: Create the Pipeline in Azure DevOps
Go to your Azure DevOps project → Pipelines → New Pipeline
Choose your repo (GitHub or Azure Repos).
Pick “YAML” and select your
azure-pipelines.ymlfile.You’ll be asked to authorize your Azure connection (Service Connection).
Save and run the pipeline.
Now, your code will automatically build and deploy to Azure each time you push new changes.
- task: AzureWebApp@1
inputs:
azureSubscription: '<your-service-connection-name>'
appName: '<your-app-service-name>'
deployToSlotOrASE: true
resourceGroupName: '<your-resource-group>'
slotName: 'staging'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
- task: AzureAppServiceManage@0
inputs:
azureSubscription: '<your-service-connection-name>'
WebAppName: '<your-app-service-name>'
ResourceGroupName: '<your-resource-group>'
SourceSlot: staging
SwapWithProduction: trueStep 4: (Optional) Deploy to a Staging Slot
You can deploy to a staging slot first — test your app, then swap it into production:
- task: AzureWebApp@1
inputs:
azureSubscription: '<your-service-connection-name>'
appName: '<your-app-service-name>'
deployToSlotOrASE: true
resourceGroupName: '<your-resource-group>'
slotName: 'staging'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
- task: AzureAppServiceManage@0
inputs:
azureSubscription: '<your-service-connection-name>'
WebAppName: '<your-app-service-name>'
ResourceGroupName: '<your-resource-group>'
SourceSlot: staging
SwapWithProduction: trueStep 5: Make It Smarter with Conditions
You can make the deployment smarter — for example, only deploy from the main branch:
- task: AzureWebApp@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
inputs:
azureSubscription: '<your-service-connection-name>'
appName: '<your-app-service-name>'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'Conclusion
Azure Pipelines takes the pain out of deployments.
Once set up, you’ll have a fully automated CI/CD pipeline — no more manual zip uploads or deployment clicks.
Whether you’re deploying:
A Web App,
A Function App, or
A Containerized App,
The process is almost the same — define your YAML, connect to Azure, and let DevOps handle the rest.

Join the conversation! Your thoughts help the community grow.