OpsCart Hub

Azure DevOps CI/CD: Getting Started

Introduction πŸš€

This guide will walk you through setting up a complete CI/CD pipeline in Azure DevOps, allowing automated building, testing, and deployment of applications.


1️⃣ Prerequisites

Before we begin, make sure you have the following:

βœ” An Azure DevOps account (Sign up here)
βœ” Installed Git (Download Git)
βœ” A code repository (GitHub, Azure Repos, or any Git-based repo)
βœ” A basic understanding of CI/CD concepts


2️⃣ Setting Up a Repository in Azure DevOps

  1. Go to Azure DevOps β†’ Navigate to Repos.
  2. Click “New Repository” and select Git.
  3. Clone the repository locally:
git clone https://dev.azure.com/your-org-name/your-repo-name/_git/your-repo-name
cd your-repo-name
echo "# Azure DevOps CI/CD" >> README.md
git add .
git commit -m "Initial commit"
git push origin main

3️⃣ Creating a CI Pipeline (Continuous Integration)

Azure DevOps uses YAML pipelines for automation.

πŸ›  Steps to Create a CI Pipeline:

  1. Navigate to Pipelines β†’ New Pipeline.
  2. Choose your repository (Azure Repos Git / GitHub / Bitbucket).
  3. Select YAML as the pipeline type.
  4. Create a .azure-pipelines.yml file in your repo with the following content:
  trigger:
    - main
  pool:
    vmImage: 'ubuntu-latest'
  steps:
    - task: UseNode@2
      inputs:
        version: '16.x'
    - script: |
        npm install
        npm run build        
      displayName: 'Install Dependencies & Build'
    - script: |
        npm test        
      displayName: 'Run Tests'
  1. Save and Run the pipeline.
  2. Check Pipeline Runs to see the execution logs.

4️⃣ Creating a CD Pipeline (Continuous Deployment)

Now, let’s deploy the application using Azure App Service.

πŸ›  Steps to Set Up CD:

  1. Navigate to Pipelines β†’ Releases β†’ New Release Pipeline.
  2. Select Azure App Service Deployment as a task.
  3. Link it to the build artifact from the CI pipeline.
  4. Configure Azure subscription and select the target App Service.
  5. Enable Continuous Deployment trigger (automatically deploy after each successful build).
  6. Save and Deploy.

5️⃣ Automating the Entire Workflow

To ensure fully automated CI/CD, update your .azure-pipelines.yml to include both build and deploy steps:

trigger:
  - main
pool:
  vmImage: 'ubuntu-latest'
steps:
  - task: UseNode@2
    inputs:
      version: '16.x'
  - script: |
      npm install
      npm run build      
    displayName: 'Install Dependencies & Build'
  - script: |
      npm test      
    displayName: 'Run Tests'
  - task: AzureWebApp@1
    inputs:
      azureSubscription: '<Azure Service Connection>'
      appName: '<Your App Name>'
      package: '$(Build.ArtifactStagingDirectory)/**/*.zip'

6️⃣ Monitoring and Troubleshooting

πŸ” Checking Pipeline Status

  • Go to Azure DevOps β†’ Pipelines β†’ Select the pipeline β†’ Run History.
  • Click on Logs to check errors or warnings. Common Issues & Fixes

Table

| Issue                                     | Solution                                                |  
|-------------------------------------------|---------------------------------------------------------|
| Build fails due to missing dependencies   | Run npm install before the build step                   | 
| Deployment fails with authentication error| Ensure the service connection is valid                  | 
| Changes not deploying automatically       | Enable the Continuous Deployment Trigger in Azure DevOps| 

Powered by 2025 OpsCart Hub. Theme by TechDoc.