Wednesday, November 12, 2025

thumbnail

Setting Up a CI/CD Pipeline for Full Stack .NET on Azure DevOps

 ☁️ Introduction


CI/CD (Continuous Integration / Continuous Deployment) automates:


Building your application


Testing it


Deploying it to staging or production


For a full stack .NET application, your pipeline will handle:


Backend: ASP.NET Core Web API or MVC


Frontend: Angular, React, or Blazor


Database migrations: EF Core or SQL scripts


Deployment: Azure App Service, Azure Kubernetes Service, or other cloud services


Using Azure DevOps makes it easier to manage pipelines, artifacts, and environment deployments in a single platform.


๐Ÿ›  Step 1: Organize Your Repository


A clean repository structure simplifies CI/CD:


/MyFullStackApp

 ├─ /Backend        # ASP.NET Core Web API

 ├─ /Frontend       # React or Angular app

 ├─ /Database       # EF Core migrations or SQL scripts

 ├─ azure-pipelines.yml

 └─ README.md



๐Ÿ’ก Keep infrastructure-as-code (IaC) scripts like ARM templates or Terraform if needed.


๐Ÿงฉ Step 2: Set Up Azure DevOps Project


Sign in to Azure DevOps


Create a new project


Connect your Git repository (Azure Repos, GitHub, or external Git)


Enable Service Connections to Azure for deployments


๐Ÿ”ง Step 3: Define Your Build Pipeline (CI)


Create a azure-pipelines.yml file at the root:


Example: Full Stack .NET Build Pipeline

trigger:

  branches:

    include:

      - main


pool:

  vmImage: 'windows-latest'


variables:

  buildConfiguration: 'Release'


stages:

  - stage: Build_Backend

    displayName: 'Build Backend API'

    jobs:

      - job: Build

        steps:

          - task: UseDotNet@2

            inputs:

              packageType: 'sdk'

              version: '8.0.x'

          - task: DotNetCoreCLI@2

            inputs:

              command: 'restore'

              projects: 'Backend/MyApp.csproj'

          - task: DotNetCoreCLI@2

            inputs:

              command: 'build'

              projects: 'Backend/MyApp.csproj'

              arguments: '--configuration $(buildConfiguration)'

          - task: DotNetCoreCLI@2

            inputs:

              command: 'test'

              projects: 'Backend/MyApp.Tests/MyApp.Tests.csproj'

          - task: DotNetCoreCLI@2

            inputs:

              command: 'publish'

              projects: 'Backend/MyApp.csproj'

              arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/backend'


  - stage: Build_Frontend

    displayName: 'Build Frontend'

    jobs:

      - job: BuildFrontend

        steps:

          - task: NodeTool@0

            inputs:

              versionSpec: '18.x'

          - script: |

              cd Frontend

              npm install

              npm run build

            displayName: 'Install and Build Frontend'

          - task: PublishBuildArtifacts@1

            inputs:

              PathtoPublish: 'Frontend/build'

              ArtifactName: 'frontend'



✅ Key Points:


Builds backend and frontend separately


Runs unit tests automatically


Publishes build artifacts for deployment


๐Ÿš€ Step 4: Define the Release Pipeline (CD)


The CD pipeline deploys your application to Azure.


Deployment Targets:


Azure App Service (simplest)


Azure Kubernetes Service (AKS)


Azure Functions (for serverless backend)


Example: Deploy Backend to Azure App Service

- stage: Deploy_Backend

  displayName: 'Deploy Backend to Azure'

  dependsOn: Build_Backend

  jobs:

    - deployment: DeployAPI

      environment: 'staging'

      pool:

        vmImage: 'windows-latest'

      strategy:

        runOnce:

          deploy:

            steps:

              - task: AzureWebApp@1

                inputs:

                  azureSubscription: 'MyAzureServiceConnection'

                  appType: 'webApp'

                  appName: 'MyBackendAppService'

                  package: '$(Build.ArtifactStagingDirectory)/backend'


Example: Deploy Frontend to Azure Storage / Static Web App

- stage: Deploy_Frontend

  displayName: 'Deploy Frontend to Azure'

  dependsOn: Build_Frontend

  jobs:

    - deployment: DeployFrontend

      environment: 'staging'

      pool:

        vmImage: 'ubuntu-latest'

      strategy:

        runOnce:

          deploy:

            steps:

              - task: AzureStaticWebApp@0

                inputs:

                  app_location: 'Frontend'

                  output_location: 'build'

                  azure_static_web_apps_api_token: '$(AZURE_STATIC_WEB_APP_TOKEN)'



๐Ÿ’ก You can promote to production by adding an approval step in Azure DevOps environments.


๐Ÿงช Step 5: Add Testing and Quality Gates


Unit Tests: Already included in build stage


Integration Tests: Run in a separate stage after backend build


Code Analysis: Use SonarCloud or .NET Code Analysis


Linting for frontend: ESLint or Prettier


Example for backend tests:


- task: DotNetCoreCLI@2

  inputs:

    command: 'test'

    projects: '**/*Tests/*.csproj'


๐Ÿ”„ Step 6: Enable Continuous Deployment


Enable triggers on the main branch (or develop for staging)


Configure release environments in Azure DevOps


Add approvals and gates for production deployments


Monitor deployment status and logs in Azure DevOps


๐Ÿ’ก With this, every push to main triggers a full build and deployment automatically.


๐Ÿง  Best Practices

Practice Why It Matters

Separate frontend & backend builds Parallel execution, faster builds

Use environment variables Keep secrets out of source code

Enable rollback Quickly recover from failed deployments

Automate database migrations Keep schema in sync

Monitor pipelines Detect issues early

๐Ÿ’ฌ Summary


A CI/CD pipeline for full stack .NET on Azure DevOps automates build, test, and deployment for backend, frontend, and database. Using Azure DevOps pipelines with artifacts, environments, and approvals ensures your app is reliable, maintainable, and deployable at any time.

Learn Dot Net Course in Hyderabad

Read More

Managing Secrets and Configuration in .NET Core

How to Scale Your Full Stack .NET Application on the Cloud

Introduction to Kubernetes with .NET Core

Using Docker for Full Stack .NET Development

Visit Our Quality Thought Institute in Hyderabad

Get Directions 

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

About

Search This Blog

Powered by Blogger.

Blog Archive