← All Posts
Azure DevOps17 Jun 2026·11 min read

Azure Pipelines YAML: Build Your First CI/CD Pipeline

Srinivasa Rao Maganti — Lead Cloud & DevOps Trainer at CloudTechTrainings

Srinivasa Rao Maganti

Cloud Architect & Lead Trainer, CloudTechTrainings

#Azure DevOps#CI/CD#YAML Pipelines#AZ-400#DevOps

YAML pipelines in Azure DevOps give you code-as-configuration for your entire CI/CD process. Unlike classic pipelines, YAML pipelines live in your Git repository — version-controlled, reviewable, and portable across projects.

Pipeline Structure Basics

An Azure Pipelines YAML file has a hierarchy: trigger → stages → jobs → steps. Here's a minimal pipeline that builds a Node.js application:

yaml
trigger:
  branches:
    include:
      - main
      - develop

pool:
  vmImage: 'ubuntu-latest'

variables:
  nodeVersion: '20.x'

stages:
  - stage: Build
    displayName: 'Build & Test'
    jobs:
      - job: BuildJob
        steps:
          - task: NodeTool@0
            inputs:
              versionSpec: $(nodeVersion)
            displayName: 'Install Node.js'

          - script: npm ci
            displayName: 'Install dependencies'

          - script: npm test
            displayName: 'Run tests'

          - task: PublishTestResults@2
            inputs:
              testResultsFiles: '**/test-results.xml'

          - task: ArchiveFiles@2
            inputs:
              rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
              archiveFile: '$(Build.ArtifactStagingDirectory)/app.zip'

          - task: PublishPipelineArtifact@1
            inputs:
              artifactName: 'drop'
              targetPath: '$(Build.ArtifactStagingDirectory)'

Adding a Deploy Stage

yaml
  - stage: Deploy
    displayName: 'Deploy to Azure'
    dependsOn: Build
    condition: succeeded()
    jobs:
      - deployment: DeployWeb
        environment: 'production'
        strategy:
          runOnce:
            deploy:
              steps:
                - task: AzureWebApp@1
                  inputs:
                    azureSubscription: 'my-azure-connection'
                    appName: 'my-app-service'
                    package: '$(Pipeline.Workspace)/drop/app.zip'

Tip: Environments and Approvals

Azure DevOps Environments let you add manual approval gates between stages. Go to Pipelines → Environments → your environment → Approvals and checks to require a reviewer before production deploys.

Pipeline Variables and Key Vault Integration

  • Store non-sensitive config in Variable Groups (Pipelines → Library)
  • Link an Azure Key Vault to a Variable Group for automatic secret injection
  • Reference variables as $(variableName) anywhere in your YAML
  • Use `${{ if eq(variables.environment, "prod") }}` for conditional steps

Warning: Security Best Practice

Never hard-code secrets, connection strings, or passwords in your YAML file. Even if your repo is private today, it may become public — and Git history is permanent.

Our Azure DevOps training covers YAML pipelines in full depth — from basic builds to multi-stage enterprise delivery pipelines with environment approvals, artifact management, and Key Vault integration.

Test Your Pipeline Knowledge

Ready to Start Your Cloud Journey?

Live batches Mon–Sat — Azure 9–10 AM IST (started 24 august 2026 — join in progress) · AWS 10:30–11:45 AM IST (starts 31 august 2026). Hands-on labs, exam prep, and community support.

Join Free Demo →WhatsApp Us

Keep Reading

Microsoft Azure
Azure DevOps

AZ-400 Study Guide 2026: How to Pass First Try

A domain-weighted study plan for AZ-400 — reflecting the domain reweight Microsoft shipped in July 2026, where pipelines now carry over half the exam. Covers prerequisites, the 5 domains, and exam-day tactics.

10 Aug 2026·12 min read
Read →
Azure DevOps

AI in Azure DevOps: Copilot, Pipelines & AIOps

Where AI actually shows up in the Azure DevOps toolchain in 2026 — GitHub Copilot in Azure Repos, AI-assisted Bicep/Terraform authoring, and Application Insights Smart Detection for AIOps. What is real, what is marketing, and what it means for your DevOps career.

9 Jul 2026·10 min read
Read →