Skip to content

This project demonstrates the setup of a **Continuous Integration and Continuous Deployment (CI/CD)** pipeline using **Azure DevOps** for a sample application. This pipeline automates the build, testing, and deployment stages, and deploys to either **Azure App Service** or **Azure Kubernetes Service (AKS)**.

Notifications You must be signed in to change notification settings

MohammedRashwan/CICD-Pipeline-Azure-Devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

πŸš€ CI/CD Pipeline for Sample Application using Azure DevOps

Overview

This project demonstrates the setup of a Continuous Integration and Continuous Deployment (CI/CD) pipeline using Azure DevOps for a sample application. This pipeline automates the build, testing, and deployment stages, and deploys to either Azure App Service or Azure Kubernetes Service (AKS).


Key Steps

πŸ”§ Step 1: Build Pipeline Configuration

  • Configure the CI pipeline in Azure DevOps to build the application, run unit tests, and create artifacts.

πŸš€ Step 2: Release Pipeline Configuration

  • Set up the CD pipeline to deploy artifacts to Azure App Service or Azure Kubernetes Service based on chosen environment.

☁️ Step 3: Azure App Service or AKS Deployment

  • Demonstrate the steps to deploy to either Azure App Service (for web applications) or AKS (for containerized applications).

Getting Started

Prerequisites

  • Azure DevOps account
  • Azure subscription with permission to deploy to Azure resources
  • Git repository containing the sample application code
  • Basic knowledge of YAML for pipeline configuration

Step-by-Step Guide

Step 1: Set Up CI Pipeline in Azure DevOps

  1. Create a New Project in Azure DevOps:

    • Go to Azure DevOps, create a new project, and link it to your Git repository.
  2. Define CI Pipeline (YAML):

    • Create a YAML file (azure-pipelines.yml) in the root directory of your repository for the CI configuration.
    • Below is a sample CI configuration:
      trigger:
        branches:
          include:
            - main
      
      pool:
        vmImage: 'ubuntu-latest'
      
      steps:
        - task: UseDotNet@2
          inputs:
            packageType: 'sdk'
            version: '6.x'
      
        - script: dotnet build
          displayName: 'Build Solution'
      
        - script: dotnet test --collect:"XPlat Code Coverage"
          displayName: 'Run Unit Tests'
      
        - task: PublishBuildArtifacts@1
          inputs:
            PathtoPublish: '$(Build.ArtifactStagingDirectory)'
            ArtifactName: 'drop'
  3. Run the CI Pipeline:

    • Commit and push the azure-pipelines.yml file to trigger the build process, which will run the defined steps, including building and testing the application.

Step 2: Set Up CD Pipeline in Azure DevOps

  1. Create a Release Pipeline:

    • In Azure DevOps, go to Pipelines > Releases and create a new release pipeline.
    • Choose the artifact generated by the CI pipeline as the source.
  2. Define Stages for Deployment:

    • Azure App Service: Add an Azure App Service Deploy task to deploy the web application.
    • Azure Kubernetes Service (AKS): Add a Kubectl apply task to deploy containers to AKS.
  3. Sample YAML for AKS Deployment:

    - stage: Deploy
      jobs:
        - deployment: DeployToAKS
          environment: 'aks'
          pool:
            vmImage: 'ubuntu-latest'
          steps:
            - task: Kubernetes@1
              inputs:
                connectionType: 'Azure Resource Manager'
                azureSubscription: '<Azure Subscription>'
                azureResourceGroup: '<Resource Group>'
                kubernetesCluster: '<AKS Cluster Name>'
                namespace: default
                command: apply
                arguments: '-f k8s/deployment.yaml'
    
  4. Configure Release Triggers:

  • Set up Continuous Deployment Trigger in the Release pipeline to automatically deploy artifacts from the build pipeline.

Deployment Options

Option 1: Deploy to Azure App Service

  • Use the Azure App Service Deploy task in the release pipeline to deploy a web application to Azure App Service.

Option 2: Deploy to Azure Kubernetes Service (AKS)

  • For containerized applications, configure the pipeline to deploy to AKS by applying the Kubernetes configuration files (e.g., deployment.yaml, service.yaml).

Summary of the Pipeline Workflow

  1. Code Commit : Push code to the repository.

  2. CI Pipeline : Triggers on each commit, building the application, running tests, and publishing artifacts.

  3. CD Pipeline : Deploys the latest build to the chosen Azure service (App Service or AKS) automatically.

Contributing : Feel free to submit issues or pull requests to suggest improvements or additional features.

License : This project is licensed under the MIT License.

About

This project demonstrates the setup of a **Continuous Integration and Continuous Deployment (CI/CD)** pipeline using **Azure DevOps** for a sample application. This pipeline automates the build, testing, and deployment stages, and deploys to either **Azure App Service** or **Azure Kubernetes Service (AKS)**.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published