Isaac.

devops

Azure Pipelines CI/CD

Automate build and deployment with Azure Pipelines.

By Emem IsaacOctober 14, 20212 min read
#azure pipelines#ci/cd#automation#yaml
Share:

A Simple Analogy

Azure Pipelines is like an automated factory assembly line. Code goes in one end and is automatically tested, built, and deployed.


Why Azure Pipelines?

  • Integration: Works with Azure DevOps
  • Multi-platform: Build on Windows, Linux, Mac
  • Free: 1800 minutes/month free for public repos
  • YAML-based: Infrastructure as code
  • Extensible: Marketplace tasks

Basic Pipeline

trigger:
  - main
  - develop

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: UseDotNet@2
  inputs:
    version: '8.0.x'

- task: DotNetCoreCLI@2
  displayName: 'Restore packages'
  inputs:
    command: 'restore'

- task: DotNetCoreCLI@2
  displayName: 'Build'
  inputs:
    command: 'build'
    arguments: '--configuration Release'

- task: DotNetCoreCLI@2
  displayName: 'Run tests'
  inputs:
    command: 'test'
    arguments: '--configuration Release'

- task: DotNetCoreCLI@2
  displayName: 'Publish'
  inputs:
    command: 'publish'
    arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish artifacts'
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: 'app'

Multi-Stage Pipeline

stages:
- stage: Build
  displayName: 'Build and Test'
  jobs:
  - job: BuildJob
    steps:
    - script: npm ci
    - script: npm run lint
    - script: npm run test

- stage: Deploy_Staging
  displayName: 'Deploy to Staging'
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    environment: 'staging'
    strategy:
      runOnce:
        deploy:
        - task: AzureAppServiceDeploy@0
          inputs:
            azureSubscription: 'MySubscription'
            appName: 'myapp-staging'

- stage: Deploy_Production
  displayName: 'Deploy to Production'
  dependsOn: Deploy_Staging
  condition: succeeded()
  jobs:
  - deployment: Deploy
    environment: 'production'
    strategy:
      runOnce:
        deploy:
        - task: AzureAppServiceDeploy@0
          inputs:
            azureSubscription: 'MySubscription'
            appName: 'myapp-prod'

Variables

variables:
  buildConfiguration: 'Release'
  artifactName: 'dist'

jobs:
- job: Build
  steps:
  - script: echo Building $(buildConfiguration)
  - script: npm run build --configuration $(buildConfiguration)
  - task: PublishBuildArtifacts@1
    inputs:
      pathToPublish: '$(System.DefaultWorkingDirectory)/$(artifactName)'

Best Practices

  1. Fail fast: Run quick checks first
  2. Cache dependencies: Speed up builds
  3. Parallel jobs: Run independent tasks together
  4. Manual gates: Require approval for production
  5. Notifications: Alert on failures

Related Concepts

  • GitHub Actions
  • GitLab CI
  • Jenkins
  • CloudBuild

Summary

Azure Pipelines automates build, test, and deployment. Use YAML to define multi-stage pipelines with different environments.

Share:

Written by Emem Isaac

Expert Software Engineer with 15+ years of experience building scalable enterprise applications. Specialized in ASP.NET Core, Azure, Docker, and modern web development. Passionate about sharing knowledge and helping developers grow.

Ready to Build Something Amazing?

Let's discuss your project and explore how my expertise can help you achieve your goals. Free consultation available.

💼 Trusted by 50+ companies worldwide | ⚡ Average response time: 24 hours