Azure Devops build and deployments
July 07, 2026 — LiveStream
Disclosure: some links above are affiliate links — if you buy through them I may earn a small commission at no extra cost to you. Thanks for supporting the channel!
Diving into the world of continuous integration and continuous deployment (CI/CD) with Azure DevOps build and deployments is a big deal for modern software development teams. This guide will walk you through setting up robust pipelines that automate your build, test, and deployment processes, making your releases smoother and more reliable.
For any software team aiming for faster release cycles and higher code quality, mastering Azure DevOps build and deployments is absolutely essential. It’s not just about pushing code; it’s about creating an efficient, repeatable, and scalable mechanism that takes your changes from commit to production with confidence. Today, we'll peel back the layers and understand how to leverage Azure DevOps to build and deploy your applications like a pro, all while keeping things simple and practical, just like you'd discuss over a cup of chai.
Before we jump into the nitty-gritty, let's establish some common ground. When we talk about CI/CD in Azure DevOps, we're essentially referring to two primary components: Build Pipelines (for Continuous Integration) and Release Pipelines (for Continuous Deployment/Delivery). Think of it like a production line in a factory. The build pipeline takes your raw materials (code), processes them (compiles, tests), and packages them (artifacts). The release pipeline then takes these finished packages and ships them to different stores (environments) for customers (users).
Yaar, the build pipeline is where your code gets its first reality check. Every time a developer commits changes to the repository, the CI pipeline kicks in. Its main job is to:
The goal here is to catch issues early, minimize integration problems, and always have a working, tested artifact ready for deployment. If the build fails, everyone knows about it immediately, and it's addressed before it becomes a bigger headache later on.
Once your build pipeline gives a thumbs-up and produces an artifact, the release pipeline takes over. This is where the magic of deployment happens. A release pipeline's job is to:
The difference between Continuous Deployment and Continuous Delivery often boils down to the final step: automatic deployment to production. With Continuous Delivery, it's ready, but a human approval might still be needed. With Continuous Deployment, if all automated checks pass, it goes straight to live! Azure DevOps supports both models smoothly.
Chalo, let’s get our hands a little dirty and talk about actually setting up a build pipeline in Azure DevOps. You have two main ways to define your pipelines: the Classic UI Editor or YAML pipelines. My recommendation? Always go with YAML pipelines. They are "Pipeline as Code," meaning your pipeline definition lives alongside your application code in your repository. This gives you version control, reusability, and makes changes trackable and reviewable.
Here’s how you’d typically kick off a new YAML build pipeline:
A basic YAML pipeline looks something like this. Let's break it down, element by element:
# Trigger the pipeline on every commit to the 'main' branch
trigger:
branches:
include:
- main
# Variables are reusable values in your pipeline
variables:
buildConfiguration: 'Release'
dotNetSdkVersion: '6.x' # Example for .NET
# Pool specifies the agent that will run your job
pool:
vmImage: 'ubuntu-latest' # Use a Microsoft-hosted agent
# Stages organize your pipeline. A build pipeline usually has one build stage.
stages:
- stage: Build
displayName: 'Build application and publish artifacts'
jobs:
- job: BuildJob
displayName: 'Compile and Test'
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: '$(dotNetSdkVersion)'
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build project'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Publish application for deployment'
inputs:
command: 'publish'
publishWebProjects: true # For web applications
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
- publish: $(Build.ArtifactStagingDirectory)
artifact: drop
displayName: 'Publish Build Artifacts'
trigger: This defines when your pipeline should run. main branch commits are the classic trigger. You can also specify pull request triggers or scheduled builds.variables: Define values that you can reuse throughout your pipeline, like build configurations or SDK versions. Makes your pipeline flexible.pool: This specifies which agent will run your job. vmImage: 'ubuntu-latest' means you're using a Microsoft-hosted Ubuntu agent. For specific requirements, you might use self-hosted agents. Self-hosted agents are super useful when you need to access internal resources or have custom software installed.stages and jobs: These are logical groupings. A pipeline can have multiple stages (e.g., Build, Test, DeployDev, DeployProd). Each stage can have one or more jobs, which are a series of steps executed sequentially.steps: This is the heart of your pipeline, a sequence of tasks to perform. Azure DevOps provides a rich marketplace of tasks (e.g., UseDotNet@2, DotNetCoreCLI@2, Npm@1, Docker@2).dotnet restore, npm install, pip install. This ensures all required libraries are available.dotnet build, npm run build, mvn package. Transforms source code into executables.dotnet test, npm test, pytest. Crucial for verifying functionality.publish task (or PublishBuildArtifacts@1 task for classic) takes the output of your build (e.g., published web app, compiled JAR) and makes it available for subsequent release pipelines. The $(Build.ArtifactStagingDirectory) is a predefined variable pointing to a local directory on the agent where artifacts are collected.Once you save and run this, Azure DevOps will execute these steps, and if everything passes, you’ll have your application artifacts published, ready for deployment. Pakka!
Ab humari turn hai deployments ki. Once you have a shining artifact from your build pipeline, the next logical step is to deploy it. Azure DevOps offers powerful capabilities for creating release pipelines, whether through the classic UI or, increasingly, as multi-stage YAML pipelines which are highly recommended for consistency and versioning.
Modern Azure DevOps pipelines can handle both CI and CD in a single YAML file, referred to as multi-stage pipelines. This is the preferred approach for simplicity and managing the entire lifecycle in one place.
# ... (Previous Build Stage from above) ...
- stage: DeployDev
displayName: 'Deploy to Development'
dependsOn: Build # This stage depends on the 'Build' stage succeeding
jobs:
- deployment: DeployWebAppDev
displayName: 'Deploy Web App to Dev'
environment: 'Development' # Links to an environment defined in Azure DevOps
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App'
inputs:
azureSubscription: 'Your Azure Service Connection' # Link to your service connection
appType: 'webAppLinux' # or 'webApp' for Windows
appName: 'your-dev-app-service'
package: '$(Pipeline.Workspace)/drop/**/*.zip' # Path to your published artifact
- task: AzureFunctionApp@1 # Example for Azure Function App deployment
displayName: 'Deploy Azure Function App'
inputs:
azureSubscription: 'Your Azure Service Connection'
appType: 'functionAppLinux'
appName: 'your-dev-function-app'
package: '$(Pipeline.Workspace)/drop/**/*.zip'
- stage: DeployProd
displayName: 'Deploy to Production'
dependsOn: DeployDev # This stage depends on 'DeployDev' succeeding
condition: succeeded('DeployDev') # Only run if Dev deployment was successful
jobs:
- deployment: DeployWebAppProd
displayName: 'Deploy Web App to Prod'
environment: 'Production' # Links to a Production environment
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App'
inputs:
azureSubscription: 'Your Azure Service Connection'
appType: 'webAppLinux'
appName: 'your-prod-app-service'
package: '$(Pipeline.Workspace)/drop/**/*.zip'
- task: AzureCLI@2 # Example for running CLI commands for post-deployment config
displayName: 'Configure Production Settings'
inputs:
azureSubscription: 'Your Azure Service Connection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp config appsettings set --name your-prod-app-service --resource-group your-resource-group --settings "MY_PROD_VAR=true"
stages and dependsOn: Clearly define the sequence of your deployments. For instance, Production deployment should only happen after Development and Staging deployments are successful.environment: This is a crucial feature in Azure DevOps. Environments are logical groupings of resources (e.g., App Services, VMs, AKS clusters) where you deploy your application. They allow you to define approvals and checks, ensuring only authorized deployments happen. You set up environments under Pipelines -> Environments.deployment Job: A special type of job in YAML pipelines designed specifically for deployments. It gives you access to deployment strategies.strategy: Defines how your application is deployed to an environment.
runOnce: The simplest strategy; deploys once.rolling: Updates instances in batches.canary: Deploys to a small subset of users, monitors, then rolls out wider.blue/green: Deploys to a completely separate "green" environment, then swaps traffic from "blue" (old) to "green" (new).Choosing the right strategy depends on your application's tolerance for downtime and risk appetite. For critical production systems, blue/green or canary deployments are often preferred.
AzureWebApp@1 / AzureFunctionApp@1: For deploying to Azure App Services or Function Apps.AzureRmWebAppDeployment@4: (Classic UI equivalent)AzureCLI@2: For executing arbitrary Azure CLI commands, offering immense flexibility for configuring resources post-deployment.KubernetesManifest@1: For deploying to Kubernetes clusters.AzureVmssDeployment@0: For deploying to Azure Virtual Machine Scale Sets.DownloadPipelineArtifact@2: Essential for downloading the build artifacts created in the previous stage or pipeline. $(Pipeline.Workspace)/drop is the standard path where artifacts are downloaded.environment in Azure DevOps. You can require manual approval from specific users/groups before a deployment to Staging or Production. You can also add automated checks, like "Invoke Azure Function" to run custom validation scripts or "Query Azure Monitor alerts" to ensure no critical alerts are firing after a deployment. This is crucial for preventing broken deployments.Dekho, by combining these elements, you can create a sophisticated and reliable deployment pipeline that automates the entire journey of your code to production. This level of automation is what makes your team highly productive and ensures consistency across environments.
So far, we've covered the basics, but to truly become an Azure DevOps guru, we need to talk about some advanced concepts and best practices. These will help you build pipelines that are not just functional but also robust, secure, and maintainable.
Security is paramount, yaar. Especially when dealing with deployments to production. Here are some pointers:
# Link a variable group to your pipeline
variables:
- group: 'MySecureSecrets' # Name of your variable group linked to Key Vault
# Use secrets like: $(mySecretPassword)
isSecret: true in YAML if defining in the YAML itself, though Key Vault is preferred).We already touched upon YAML, but let’s emphasize why it’s a non-negotiable best practice:
# azure-pipelines.yml
stages:
- template: templates/build-template.yml # Use a template
parameters:
solution: '**/*.sln'
testProject: '**/*Tests.csproj'
And then templates/build-template.yml would contain the generic build logic.
Once deployed, your application needs to be monitored. Integrate your pipelines with monitoring tools:
Pipelines can fail for many reasons. Here's a quick checklist:
Always start by examining the detailed logs of the failed task. The error messages often give good clues. Kabhi ghabrana nahi, it's part of the process!
While Azure DevOps deploys your application, managing the underlying infrastructure is also key. Integrate IaC tools like Terraform or Bicep into your pipelines. A common pattern is:
terraform plan) and publish it as an artifact.terraform apply) to create or update infrastructure.This ensures your infrastructure is versioned and deployed reliably, just like your application. Terraform with Azure DevOps is a powerful combo!
By focusing on these advanced practices, you're not just automating; you're building a resilient, secure, and highly efficient DevOps culture that will serve your team well. Remember, continuous improvement is key!
A build pipeline focuses on Continuous Integration (CI): it compiles your code, runs tests, and packages deployable artifacts from your source code. A release pipeline (or the deployment stages of a multi-stage YAML pipeline) focuses on Continuous Deployment/Delivery (CD): it takes those artifacts and deploys them to specific environments (like Dev, Staging, Production), often involving approvals and configurations.
The most secure way to handle sensitive information is by using Variable Groups linked to Azure Key Vault. This allows your pipeline to fetch secrets securely at runtime without exposing them in your pipeline definition or logs. Avoid hardcoding secrets directly in YAML or using plain pipeline variables for critical information.
Yes, absolutely! Modern multi-stage YAML pipelines in Azure DevOps are designed precisely for this. You define separate stages for each environment, and use dependsOn to specify the deployment order. You can also configure environment-specific approvals and checks to ensure quality and control as your application progresses through different environments.
I hope this deep dive into Azure DevOps build and deployments has given you a clear roadmap and some solid insights. This is a vast topic, and the best way to master it is by actually doing it! So, grab your chai, open Azure DevOps, and start experimenting with your pipelines.
For a visual walkthrough and to see these concepts in action, make sure to watch the full video on this topic. Don't forget to like the video and subscribe to @explorenystream for more awesome content!