Showing posts with label Azure DevOps. Show all posts
Showing posts with label Azure DevOps. Show all posts

Sunday, August 16, 2026

Complete CI/CD Pipeline for .NET 9 Microservices on Azure Using Azure DevOps, Docker, ACR and AKS

 


Complete CI/CD Pipeline for .NET 9 Microservices on Azure Using Azure DevOps, Docker, ACR and AKS

Introduction

Modern enterprise applications require a reliable and automated process for building, testing, packaging, and deploying applications across multiple environments.

In a typical microservices-based application, developers continuously make changes to individual services. Manually building and deploying these services is time-consuming and error-prone.

This is where CI/CD — Continuous Integration and Continuous Delivery/Deployment — becomes extremely important.

In this article, we will build a complete CI/CD pipeline for the following enterprise architecture:

  • Angular Web Application

  • .NET 9 Web API / Microservices

  • Docker

  • Azure Container Registry (ACR)

  • Azure Kubernetes Service (AKS)

  • Azure SQL Database

  • Azure Service Bus

  • Azure Key Vault

  • Azure DevOps

  • Kubernetes Ingress

  • DEV, QA, UAT and PRODUCTION environments

We will specifically use the Azure DevOps Classic/Visual UI approach, so you can understand how to configure the pipeline directly through the Azure DevOps portal without initially writing an azure-pipelines.yml file.

Note: Microsoft recommends YAML pipelines for new development, but Classic pipelines remain useful for understanding the Azure DevOps pipeline concepts and for organizations that still use the Classic UI.


1. What Are We Going to Build?

The overall CI/CD architecture will look like this:

Developer
    |
    | Git Push
    v
Azure Repos
    |
    v
+-----------------------------+
|       CI / Build Pipeline   |
|                             |
|  1. Restore                 |
|  2. Build                   |
|  3. Unit Test               |
|  4. Publish                 |
|  5. Docker Build            |
|  6. Docker Push             |
+-------------+---------------+
              |
              v
      Azure Container Registry
              |
              | Docker Image
              v
+-----------------------------+
|      CD / Release Pipeline  |
|                             |
|       DEV                   |
|         |                   |
|         v                   |
|       QA                    |
|         |                   |
|         v                   |
|       UAT                   |
|         |                   |
|     Approval                |
|         |                   |
|         v                   |
|     PRODUCTION              |
+-------------+---------------+
              |
              v
             AKS
              |
       +------+------+
       |      |      |
       v      v      v
    Order  Customer Product
     API     API     API

The basic principle is:

Code → Build → Test → Docker Image → ACR → Deploy → AKS


2. Prerequisites

Before creating the pipeline, we need several Azure and Azure DevOps resources.

Azure Resources

You should have:

  • Azure Subscription

  • Resource Group

  • Azure Container Registry

  • Azure Kubernetes Service

  • Azure SQL Database

  • Azure Service Bus

  • Azure Key Vault

  • Azure Monitor / Application Insights

Azure DevOps

You should have:

  • Azure DevOps Organization

  • Azure DevOps Project

  • Azure Repos

  • Pipeline permissions

  • Microsoft-hosted agent capability

Microsoft-hosted agents are suitable for many standard .NET builds. Self-hosted agents can be used when an organization requires custom tooling or private-network access.


3. Example Enterprise Application

Let's assume our solution has the following structure:

EnterpriseApp
│
├── EnterpriseApp.sln
│
├── src
│   ├── CustomerService
│   │   └── CustomerService.csproj
│   │
│   ├── OrderService
│   │   └── OrderService.csproj
│   │
│   └── ProductService
│       └── ProductService.csproj
│
├── tests
│   └── OrderService.Tests
│
├── Dockerfile
│
└── k8s
    ├── namespace.yaml
    ├── order-deployment.yaml
    ├── order-service.yaml
    ├── customer-deployment.yaml
    ├── customer-service.yaml
    └── ingress.yaml

For our first example, we will deploy:

OrderService

Once the process is understood, the same approach can be applied to:

  • CustomerService

  • ProductService

  • InventoryService

  • PaymentService

  • NotificationService

  • Other microservices


4. Step 1 — Create an Azure DevOps Project

Open your Azure DevOps organization and create a project.

For example:

Organization
    |
    └── EnterpriseProject

Inside the project, Azure DevOps provides services such as:

Boards
Repos
Pipelines
Test Plans
Artifacts

For our CI/CD implementation, the most important areas are:

Repos
Pipelines
Project Settings

5. Step 2 — Add Source Code to Azure Repos

Navigate to:

Repos
    |
    └── Files

Create or import your Git repository.

For example:

EnterpriseApp

The repository might contain:

EnterpriseApp.sln

src/
    CustomerService/
    OrderService/
    ProductService/

tests/
    OrderService.Tests/

Dockerfile

k8s/

Developers can then work with the repository using Git:

git clone <repository>

After making changes:

git add .
git commit -m "Update order validation"
git push

This Git push can eventually trigger the CI pipeline automatically.


6. Step 3 — Create Azure Container Registry

The Azure Container Registry (ACR) stores the Docker images generated by the CI pipeline.

In the Azure Portal:

Create a resource
        ↓
Container Registry

For example:

Registry Name:
enterpriseacr

The registry endpoint could be:

enterpriseacr.azurecr.io

Our Docker image can then be tagged as:

enterpriseacr.azurecr.io/order-service:1.0

or, preferably, with a unique build number:

enterpriseacr.azurecr.io/order-service:1234

Using a unique build identifier makes it easier to identify exactly which source version produced a container image.


7. Step 4 — Create Azure Kubernetes Service

Create an AKS cluster from the Azure Portal or Azure CLI.

For example:

EnterpriseAKS

An AKS cluster contains:

AKS Cluster
    |
    ├── Node Pools
    |
    ├── Kubernetes Control Plane
    |
    └── Workloads

After connecting your local environment to the cluster, you can verify the nodes:

kubectl get nodes

8. Step 5 — Connect ACR with AKS

AKS needs permission to pull Docker images from Azure Container Registry.

A common Azure CLI approach is:

az aks update \
  --resource-group EnterpriseRG \
  --name EnterpriseAKS \
  --attach-acr enterpriseacr

The relationship becomes:

Azure Container Registry
          |
          | Pull Docker Image
          v
         AKS

This is important because the CI pipeline pushes the image into ACR, while AKS pulls that image when deploying the application.


9. Step 6 — Create Azure DevOps Service Connection

Azure DevOps needs permission to access Azure resources.

Navigate to:

Azure DevOps
    ↓
Project Settings
    ↓
Service connections
    ↓
New service connection

Select:

Azure Resource Manager

Configure the connection according to your organization's authentication and security requirements.

For example:

Service Connection Name:

Azure-Enterprise-Connection

Conceptually:

Azure DevOps
       |
       | Service Connection
       v
Azure Subscription
       |
       +---- ACR
       +---- AKS
       +---- Other Azure Resources

Service connections are a critical security boundary, so they should be granted only the permissions required by the pipeline.


10. Step 7 — Create the CI Build Pipeline

Now we can create the Continuous Integration pipeline.

Navigate to:

Pipelines
    ↓
Builds

Depending on your Azure DevOps UI, select the option to create a new pipeline and choose the Classic editor.

The Classic editor allows you to configure the build process using the Azure DevOps UI rather than writing YAML.

Select:

Azure Repos Git

Then select:

Project:
EnterpriseProject

Repository:
EnterpriseApp

Branch:
main

Click:

Continue

11. Step 8 — Select Empty Job

Instead of allowing Azure DevOps to automatically create all the tasks, select:

Empty Job

You should now see something similar to:

Agent Job 1

This approach is useful when learning CI/CD because you can understand each pipeline task individually.


12. Step 9 — Configure the Build Agent

Select:

Agent Job 1

Choose an agent specification.

For example:

ubuntu-latest

or:

windows-latest

For Docker and Linux-based containers, Ubuntu is commonly convenient.

Our pipeline now starts with:

Agent Job
     |
     v
Use .NET SDK

13. Step 10 — Install / Select .NET SDK

Add a task:

+

Search for the .NET SDK task.

Configure the required .NET version.

For example:

SDK Version:

9.x

This ensures that the build agent uses the expected .NET SDK version.


14. Step 11 — Restore NuGet Packages

Add a .NET Core task.

Configure:

Command:

restore

For example:

Path to project:

EnterpriseApp.sln

The pipeline becomes:

Use .NET SDK
      |
      v
Restore

This downloads the NuGet dependencies required by the solution.


15. Step 12 — Build the Application

Add another .NET task.

Configure:

Command:

build

Project:

EnterpriseApp.sln

Arguments:

--configuration Release --no-restore

The pipeline is now:

Use .NET SDK
      |
      v
Restore
      |
      v
Build

The equivalent .NET CLI operation is:

dotnet build EnterpriseApp.sln \
    --configuration Release \
    --no-restore

16. Step 13 — Execute Unit Tests

Add another .NET task.

Configure:

Command:

test

Project:

tests/**/*.csproj

Arguments:

--configuration Release --no-build

The pipeline becomes:

Restore
   |
   v
Build
   |
   v
Unit Tests

If the unit tests fail:

Build ❌

the pipeline should stop.

This is an important CI principle:

Code should not progress toward deployment if automated tests are failing.


17. Step 14 — Publish the .NET Application

Add another .NET task.

Configure:

Command:

publish

Project:

src/OrderService/OrderService.csproj

Configuration:

Release

Output:

$(Build.ArtifactStagingDirectory)/order-service

The flow becomes:

Build
  |
  v
Test
  |
  v
Publish
  |
  v
Build Artifact

18. Step 15 — Build the Docker Image

Now we move from application build to containerization.

Add a Docker task.

Select:

Docker

Command:

Build

Configure the Azure Container Registry connection.

Repository:

order-service

Dockerfile:

$(Build.SourcesDirectory)/src/OrderService/Dockerfile

Tag:

$(Build.BuildId)

The resulting image could be:

enterpriseacr.azurecr.io/order-service:1234

19. Step 16 — Push Docker Image to ACR

Add another Docker task.

Select:

Docker

Command:

Push

Repository:

order-service

Tag:

$(Build.BuildId)

The CI process is now:

Git Push
    |
    v
Restore
    |
    v
Build
    |
    v
Unit Test
    |
    v
Publish
    |
    v
Docker Build
    |
    v
Docker Push
    |
    v
Azure Container Registry

This is the core Continuous Integration workflow.


20. Step 17 — Save and Run the CI Pipeline

Save the pipeline with a name such as:

CI-OrderService

Then select:

Save & Queue

Run the pipeline.

You should see tasks such as:

✔ Restore
✔ Build
✔ Unit Test
✔ Publish
✔ Docker Build
✔ Docker Push

If everything succeeds:

BUILD SUCCESSFUL

21. Step 18 — Verify the Docker Image in ACR

Open:

Azure Portal
    ↓
Container Registry
    ↓
Repositories

You should see:

order-service

Inside the repository:

order-service
    |
    └── 1234

The tag 1234 represents the pipeline build number.


22. Step 19 — Create the CD / Release Pipeline

The next step is Continuous Delivery/Deployment.

In the Classic pipeline model, the release pipeline is separate from the build pipeline.

Navigate to:

Pipelines
    ↓
Releases
    ↓
New pipeline

Select:

Empty Job

Rename the first stage:

DEV

A typical enterprise release pipeline can contain:

DEV
  |
  v
QA
  |
  v
UAT
  |
  v
PRODUCTION

23. Step 20 — Configure the Release Artifact

Add the output from the CI/build process as the release artifact.

For containerized applications, the key deployment input is the Docker image and its version/tag stored in ACR.

Conceptually:

CI Pipeline
     |
     v
Docker Image
     |
     v
ACR
     |
     v
Release Pipeline
     |
     v
AKS

24. Step 21 — Configure DEV Deployment

Open the DEV stage.

Add a Kubernetes deployment task.

Configure the Azure connection:

Connection Type:

Azure Resource Manager

Select:

Azure Subscription:

Azure-Enterprise-Connection

Then select the AKS cluster:

EnterpriseAKS

Use a namespace such as:

dev

This allows the same AKS cluster to host workloads for multiple environments when that is appropriate for the organization's architecture.


25. Kubernetes Deployment

A simplified Kubernetes Deployment might look like:

apiVersion: apps/v1
kind: Deployment

metadata:
  name: order-service

spec:
  replicas: 3

  selector:
    matchLabels:
      app: order-service

  template:
    metadata:
      labels:
        app: order-service

    spec:
      containers:
        - name: order-service

          image: enterpriseacr.azurecr.io/order-service:1234

          ports:
            - containerPort: 8080

The important part is:

image: enterpriseacr.azurecr.io/order-service:1234

When a new version is released, the image tag changes.

For example:

Old:

order-service:1233

becomes:

New:

order-service:1234

Kubernetes then performs a rollout to replace the old application version with the new one.


26. DEV Deployment Flow

The deployment now looks like:

ACR
 |
 | order-service:1234
 v
AKS
 |
 v
DEV Namespace
 |
 +---- Pod 1
 |
 +---- Pod 2
 |
 +---- Pod 3

Running multiple replicas provides application redundancy and enables Kubernetes to distribute traffic across available Pods.


27. Step 22 — Create QA Stage

Add another stage:

QA

Configure the deployment to target:

QA

and use the appropriate Kubernetes namespace:

qa

The pipeline becomes:

DEV
 |
 v
QA

Configure the QA stage to execute after successful DEV deployment.


28. Step 23 — Create UAT Stage

Create another stage:

UAT

The release flow becomes:

DEV
 |
 v
QA
 |
 v
UAT

UAT is generally used for business/user acceptance validation before production.


29. Step 24 — Create Production Stage

Create the final stage:

PRODUCTION

The complete release flow is now:

DEV
 |
 v
QA
 |
 v
UAT
 |
 v
PRODUCTION

30. Step 25 — Add Production Approval

Production deployments should normally have appropriate controls.

Instead of allowing:

Developer
   |
   v
DEV
   |
   v
QA
   |
   v
UAT
   |
   v
PRODUCTION

without any control, introduce an approval gate:

DEV
 |
 v
QA
 |
 v
UAT
 |
 v
+----------------------+
| Production Approval  |
|                      |
| Lead / Manager       |
+----------+-----------+
           |
           v
      PRODUCTION

In the Classic Release pipeline, configure:

PRODUCTION
    ↓
Pre-deployment conditions
    ↓
Pre-deployment approvals

Add the authorized reviewers according to your organization's release-management process.


31. Complete CI/CD Architecture

The complete architecture now looks like this:

                         DEVELOPER
                             |
                             | Git Push
                             v
                      +--------------+
                      | Azure Repos  |
                      +------+-------+
                             |
                             v
                  +----------------------+
                  |    CI / BUILD        |
                  |                      |
                  | Restore              |
                  | Build                |
                  | Unit Test            |
                  | Publish              |
                  | Docker Build         |
                  | Docker Push          |
                  +----------+-----------+
                             |
                             v
                  +----------------------+
                  | Azure Container      |
                  | Registry (ACR)       |
                  +----------+-----------+
                             |
                             v
                  +----------------------+
                  |    CD / RELEASE      |
                  +----------+-----------+
                             |
                             v
                        +---------+
                        |   DEV   |
                        +----+----+
                             |
                             v
                        +---------+
                        |   QA    |
                        +----+----+
                             |
                             v
                        +---------+
                        |   UAT   |
                        +----+----+
                             |
                          Approval
                             |
                             v
                     +---------------+
                     | PRODUCTION    |
                     +-------+-------+
                             |
                             v
                            AKS
                             |
             +---------------+---------------+
             |               |               |
             v               v               v
        Customer API    Order API       Product API

32. Where Does Ingress Fit?

Ingress is part of the Kubernetes application architecture. It is not a replacement for Azure DevOps.

A typical AKS architecture can look like:

                         Internet
                            |
                            v
                     +--------------+
                     |    Ingress   |
                     |   / Gateway  |
                     +------+-------+
                            |
              +-------------+-------------+
              |             |             |
              v             v             v
        Customer API    Order API    Product API
              |             |             |
              v             v             v
            Pods          Pods          Pods
              |             |             |
              +-------------+-------------+
                            |
                   +--------+--------+
                   |                 |
                   v                 v
              Azure SQL       Azure Service Bus

The important distinction is:

Azure DevOps automates application delivery.

Kubernetes/AKS runs the application.

Ingress/Gateway manages incoming application traffic.


33. Where Do Azure SQL and Azure Service Bus Fit?

Azure SQL and Azure Service Bus are generally infrastructure dependencies rather than resources that should be recreated every time the application pipeline runs.

A typical environment contains:

Azure Infrastructure
    |
    +── AKS
    |
    +── ACR
    |
    +── Azure SQL
    |
    +── Azure Service Bus
    |
    +── Key Vault
    |
    +── Monitoring

The CI/CD pipeline then deploys the application:

CI/CD
   |
   v
AKS

The application can communicate with:

Order API
    |
    +---- Azure SQL
    |
    +---- Azure Service Bus

34. Managing Secrets

Sensitive information should never be hardcoded into:

  • Source code

  • Dockerfiles

  • Kubernetes manifests

  • Pipeline scripts

  • Git repositories

Examples include:

SQL connection strings
Service Bus credentials
JWT secrets
API keys
Third-party credentials

A recommended architecture is:

                    Azure Key Vault
                          |
                          |
                    Managed Identity
                          |
                          v
                         AKS
                          |
                          v
                    Microservices

Azure DevOps variable/secret mechanisms can also be used where appropriate, but secrets should be managed according to your organization's security architecture.


35. What Happens When a Developer Commits Code?

Suppose a developer changes the OrderService validation logic.

The developer executes:

git add .

Then:

git commit -m "Update order validation"

Then:

git push origin main

The automated process becomes:

Git Push
   |
   v
CI Trigger
   |
   v
Restore
   |
   v
Build
   |
   v
Unit Tests
   |
   v
Docker Build
   |
   v
Docker Image
   |
   v
ACR
   |
   v
Release Pipeline
   |
   v
DEV
   |
   v
QA
   |
   v
UAT
   |
   v
Approval
   |
   v
PRODUCTION

This is the essence of CI/CD.


36. Continuous Integration vs Continuous Delivery

Understanding the difference between CI and CD is important.

Continuous Integration

Continuous Integration focuses on validating the application whenever code changes.

Code
 |
 v
Restore
 |
 v
Build
 |
 v
Test
 |
 v
Package
 |
 v
Docker Image
 |
 v
ACR

The primary question is:

"Is my code buildable, testable and packageable?"


Continuous Delivery / Deployment

Continuous Delivery/Deployment focuses on moving the validated application version through environments.

ACR
 |
 v
DEV
 |
 v
QA
 |
 v
UAT
 |
 v
Approval
 |
 v
PRODUCTION

The primary question is:

"Can this version be safely deployed to the required environments?"

Therefore:

CI = Build, test and package the application

CD = Deliver/deploy the application through environments


37. Classic Pipeline vs YAML Pipeline

The Classic UI is an excellent way to learn Azure DevOps because you can visually see:

Agent
Tasks
Stages
Artifacts
Approvals
Deployment

However, for modern enterprise projects, YAML pipelines are often preferred because the pipeline definition can be stored alongside the source code.

A modern architecture can look like:

Azure DevOps
      |
      v
YAML Pipeline
      |
      +---- CI
      |
      +---- Build
      |
      +---- Unit Tests
      |
      +---- Docker
      |
      +---- Security
      |
      +---- ACR
      |
      +---- CD
             |
             +---- DEV
             |
             +---- QA
             |
             +---- UAT
             |
             +---- PROD

The key advantage is Pipeline as Code.

The pipeline itself becomes version-controlled, reviewable, and reproducible.


38. Recommended Enterprise Improvements

The basic pipeline described above can be extended significantly for production environments.

Security

Add:

  • Azure Key Vault

  • Managed Identity

  • Microsoft Entra ID

  • Container image scanning

  • Dependency scanning

  • Secret scanning

  • Least-privilege service connections

Quality

Add:

  • Unit tests

  • Integration tests

  • Code coverage

  • SonarQube/SonarCloud

  • API testing

  • Performance testing

Deployment

Add:

  • Rolling deployments

  • Health probes

  • Readiness probes

  • Liveness probes

  • Deployment strategies

  • Automatic rollback

  • Environment approvals

Observability

Add:

  • Application Insights

  • Azure Monitor

  • Log Analytics

  • Kubernetes monitoring

  • Alerts

  • Dashboards


39. Production-Ready Microservices Flow

A mature enterprise architecture could eventually look like:

                         Developer
                             |
                             v
                        Azure Repos
                             |
                             v
                    Azure DevOps CI
                             |
          +------------------+------------------+
          |                  |                  |
          v                  v                  v
      Build/Test        Security Scan       Code Quality
          |                  |                  |
          +------------------+------------------+
                             |
                             v
                         Docker Build
                             |
                             v
                           ACR
                             |
                             v
                    Deployment Pipeline
                             |
            +----------------+----------------+
            |                |                |
            v                v                v
           DEV              QA               UAT
                                             |
                                         Approval
                                             |
                                             v
                                         PROD
                                             |
                                             v
                                            AKS
                                             |
                         +-------------------+-------------------+
                         |                   |                   |
                         v                   v                   v
                    Customer API        Order API          Product API
                         |                   |                   |
                         +-------------------+-------------------+
                                             |
                    +------------------------+----------------------+
                    |                                               |
                    v                                               v
                Azure SQL                                  Azure Service Bus
                    |
                    v
               Application
                 Insights
                    |
                    v
               Azure Monitor

40. Important Takeaways

The complete deployment journey can be remembered as:

Developer
   ↓
Git
   ↓
Azure DevOps
   ↓
CI
   ↓
Build
   ↓
Test
   ↓
Docker
   ↓
ACR
   ↓
CD
   ↓
DEV
   ↓
QA
   ↓
UAT
   ↓
Approval
   ↓
PRODUCTION
   ↓
AKS

The responsibilities of the major components are:

ComponentResponsibility
Azure ReposSource-code management
Azure DevOpsCI/CD automation
DockerApplication containerization
ACRDocker image storage
AKSContainer orchestration
KubernetesApplication workload management
Ingress/GatewayIncoming traffic routing
Azure SQLRelational database
Azure Service BusAsynchronous messaging
Key VaultSecret management
Application InsightsApplication telemetry
Azure MonitorMonitoring and alerting

41. Final Conclusion

Implementing CI/CD for a .NET microservices application on Azure provides a repeatable and controlled way to move software from development to production.

The complete lifecycle is:

Code
  ↓
Commit
  ↓
Build
  ↓
Unit Test
  ↓
Docker Image
  ↓
Azure Container Registry
  ↓
AKS Deployment
  ↓
DEV
  ↓
QA
  ↓
UAT
  ↓
Production Approval
  ↓
PRODUCTION

For learning Azure DevOps, the Classic UI pipeline is a very useful starting point because every stage and task is visible through the portal.

For a new enterprise implementation, however, it is worth moving toward YAML-based pipelines, infrastructure as code, automated security scanning, managed identities, automated testing, deployment strategies, and comprehensive monitoring.

The ultimate goal is not simply to automate deployment.

The goal is to create a secure, repeatable, observable, and reliable software delivery process.


Quick Reference

CI

Git
 ↓
Restore
 ↓
Build
 ↓
Test
 ↓
Publish
 ↓
Docker Build
 ↓
Docker Push
 ↓
ACR

CD

ACR
 ↓
DEV
 ↓
QA
 ↓
UAT
 ↓
Approval
 ↓
PRODUCTION
 ↓
AKS

Application Architecture

Internet
   ↓
Ingress / Gateway
   ↓
Microservices
   ↓
Azure SQL
   +
Azure Service Bus
   +
Key Vault
   +
Application Insights

This architecture provides a strong foundation for deploying modern .NET 9 microservices applications on Azure using Azure DevOps, Docker, ACR and AKS.

Friday, July 31, 2026

Azure DevOps

Microsoft Azure DevOps official documentation

Azure DevOps — Complete Guide for .NET Lead

1. What is Azure DevOps?

Azure DevOps is a set of services for planning, developing, testing, deploying, and monitoring software.

Think of a typical .NET project:

Developer
    |
    v
Write C# Code
    |
    v
Git Repository
    |
    v
Build
    |
    v
Unit Tests
    |
    v
Code Quality
    |
    v
Deploy to DEV
    |
    v
Testing
    |
    v
Deploy to QA
    |
    v
Deploy to Production
    |
    v
Azure Monitor / Application Insights

Azure DevOps helps automate this entire process.


2. Main Azure DevOps Services

You should remember these:

Azure DevOps
    |
    +-- Azure Repos
    |
    +-- Azure Pipelines
    |
    +-- Azure Boards
    |
    +-- Azure Test Plans
    |
    +-- Azure Artifacts

Easy way to remember

ServicePurpose
Azure ReposSource Code
Azure PipelinesCI/CD
Azure BoardsWork Management
Azure Test PlansTesting
Azure ArtifactsPackage Management

3. Real-Time Project

Let's take a real enterprise application:

Angular Frontend
       |
       v
ASP.NET Core Web API
       |
       +---- Azure SQL
       |
       +---- Azure Service Bus
       |
       +---- Azure Functions
       |
       +---- Azure Storage

Developers work on:

C#
Angular
SQL
Azure

Now imagine 10 developers working on the same project.

Azure DevOps provides the platform for:

Planning
   ↓
Coding
   ↓
Pull Request
   ↓
Review
   ↓
Build
   ↓
Unit Tests
   ↓
Security/Quality checks
   ↓
Deployment
   ↓
Monitoring

4. Azure Repos

Azure Repos provides Git repositories for source control.

Example:

MyCompany
   |
   +-- OrderManagement
   |
   +-- PaymentService
   |
   +-- InventoryService

You can use:

git clone
git pull
git push
git branch
git merge

just like other Git hosting platforms.


5. Typical Git Workflow

Suppose you are developing an Order API.

You shouldn't directly modify the production branch.

Instead:

main
 |
 +---- feature/order-api

Developer:

git checkout -b feature/order-api

Develop code:

OrderController.cs
OrderService.cs
OrderRepository.cs

Then:

git add .
git commit -m "Add order API"
git push origin feature/order-api

Then create:

Pull Request

6. Pull Request

The PR process is very important for a Lead.

Developer
    |
    v
Feature Branch
    |
    v
Pull Request
    |
    +---- Code Review
    +---- Build
    +---- Unit Tests
    +---- Quality Checks
    |
    v
Approve
    |
    v
Merge

A Lead should establish policies such as:

  • Minimum reviewers

  • Build validation

  • Linked work items

  • No direct pushes to main

  • Required checks

  • Branch naming conventions


7. Branching Strategy

For many enterprise projects:

main
 |
 +-- develop
      |
      +-- feature/order
      |
      +-- feature/payment
      |
      +-- bugfix/order

Another common approach is trunk-based development:

main
 |
 +-- short-lived feature branch
 |
 +-- short-lived feature branch
 |
 +-- short-lived feature branch

Lead-level point

Don't say:

"Git Flow is always the best."

Instead:

"I choose the branching strategy based on release frequency, team size, deployment model, and whether we use feature flags or continuous delivery."

That's a stronger architectural answer.


8. Azure Boards

Azure Boards is used to manage work.

Typical hierarchy:

Epic
  |
  +-- Feature
        |
        +-- User Story
              |
              +-- Task
              +-- Bug

Example:

Epic:
E-Commerce Platform

Feature:
Order Management

User Story:
As a customer, I want to place an order.

Tasks:
- Create Order API
- Create Order table
- Add validation
- Write unit tests
- Create Angular UI

9. Agile Sprint

Example:

Sprint 1
------------------------
Order API
Payment API
Login
Customer API

Azure Boards helps track:

To Do
   ↓
In Progress
   ↓
Code Review
   ↓
Testing
   ↓
Done

10. Azure Pipelines

This is probably the most important Azure DevOps feature for a .NET Lead.

Azure Pipelines automates:

Build
Test
Package
Deploy

This is called CI/CD.


11. What is CI?

Continuous Integration

Developers frequently merge code into the shared repository.

Every change triggers:

Git Push
   ↓
Pipeline
   ↓
Restore
   ↓
Build
   ↓
Unit Test
   ↓
Quality Checks

If build/test fails:

Pipeline FAILED

The developer fixes it before the change progresses.


12. What is CD?

Continuous Delivery/Deployment

After successful CI:

Build
   ↓
Test
   ↓
Deploy DEV
   ↓
Deploy QA
   ↓
Approval
   ↓
Deploy Production

13. Complete CI/CD Pipeline

For a .NET application:

                    Developer
                        |
                        v
                   Azure Repos
                        |
                        v
                   Pull Request
                        |
                        v
                 Build Validation
                        |
             +----------+----------+
             |                     |
             v                     v
         dotnet build         dotnet test
             |                     |
             +----------+----------+
                        |
                        v
                  Create Artifact
                        |
                        v
                     DEV
                        |
                        v
                  Integration Test
                        |
                        v
                     QA
                        |
                        v
                  Approval/Gate
                        |
                        v
                   Production
                        |
                        v
               Application Insights

This is a very strong diagram to explain during interviews.


14. Azure Pipeline YAML

A basic .NET pipeline can look like:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '9.x'

- script: dotnet restore
  displayName: 'Restore'

- script: dotnet build --configuration $(buildConfiguration) --no-restore
  displayName: 'Build'

- script: dotnet test --configuration $(buildConfiguration) --no-build
  displayName: 'Run Unit Tests'

- script: dotnet publish \
          --configuration $(buildConfiguration) \
          --output $(Build.ArtifactStagingDirectory)
  displayName: 'Publish'

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: 'drop'

The exact task versions and recommended YAML patterns can evolve, so use Microsoft's current task documentation when building a production pipeline.

Azure Pipelines documentation


15. Let's Understand the Pipeline

Step 1 — Trigger

trigger:
- main

Means:

Run the pipeline when changes are pushed to main.


Step 2 — Agent

pool:
  vmImage: 'ubuntu-latest'

Azure DevOps provides an agent to execute pipeline steps.

Conceptually:

Azure DevOps
     |
     v
Build Agent
     |
     +-- Restore
     +-- Build
     +-- Test
     +-- Publish

16. Restore

- script: dotnet restore

Restores NuGet dependencies.


17. Build

- script: dotnet build --configuration Release

Compiles the application.

If C# has errors:

Build FAILED

The deployment doesn't continue.


18. Unit Testing

- script: dotnet test

Suppose:

100 Tests
98 Passed
2 Failed

Pipeline:

FAILED

This prevents broken code from moving forward.


19. Publish

dotnet publish

Creates deployable output.

Conceptually:

Source Code
    ↓
Build
    ↓
Publish
    ↓
Artifact

20. What is an Artifact?

An artifact is the output produced by the build that can be used later by deployment stages.

Example:

Build
  |
  v
drop.zip

Then:

drop.zip
   |
   +---- DEV
   |
   +---- QA
   |
   +---- PROD

A key Lead-level principle is:

Build once, deploy the same artifact through environments.

You don't want to rebuild differently for production.


21. Multi-Stage Pipeline

A better enterprise pipeline:

stages:

- stage: Build
  jobs:
  - job: Build
    steps:
    - script: dotnet restore

    - script: dotnet build --configuration Release

    - script: dotnet test --configuration Release

    - script: dotnet publish \
              --configuration Release \
              --output $(Build.ArtifactStagingDirectory)

    - publish: $(Build.ArtifactStagingDirectory)
      artifact: drop


- stage: DeployDev
  dependsOn: Build
  jobs:
  - deployment: Deploy
    environment: Dev
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop


- stage: DeployQA
  dependsOn: DeployDev
  jobs:
  - deployment: Deploy
    environment: QA
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop

This demonstrates the concept:

Build
 ↓
Artifact
 ↓
DEV
 ↓
QA
 ↓
PROD

22. Environments

Azure DevOps environments represent deployment targets such as:

DEV
QA
UAT
PROD

Example:

Build
 |
 v
DEV
 |
 v
QA
 |
 v
UAT
 |
 v
PROD

23. Production Approval

Suppose your pipeline reaches:

Deploy Production

You can require an approval:

Pipeline
   |
   v
Production
   |
Approval required
   |
   v
Manager/Lead approves
   |
   v
Deployment

This is important for controlled enterprise releases.


24. Variable Groups

Don't hard-code environment configuration into YAML.

Bad:

SqlConnectionString: "Server=..."

Instead, use variables/configuration mechanisms.

Example:

Variable Group
      |
      +-- Dev
      +-- QA
      +-- Prod

Then:

DEV → Dev configuration
QA  → QA configuration
PROD → Prod configuration

For sensitive secrets, prefer Azure Key Vault integration rather than plain pipeline variables wherever appropriate.


25. Azure Key Vault + Azure DevOps

A strong enterprise architecture:

Azure DevOps Pipeline
       |
       v
Azure Key Vault
       |
       +---- SQL connection information
       +---- API secrets
       +---- Certificates
       +---- Other secrets

The pipeline doesn't need secrets embedded in source code.


26. Azure DevOps + App Service

Suppose your application is deployed to:

Azure App Service documentation

Architecture:

Azure Repos
     |
     v
Azure Pipeline
     |
     v
Build
     |
     v
Test
     |
     v
Artifact
     |
     v
Azure App Service

27. Azure DevOps + Azure Functions

Exactly the same principle:

Git
 |
 v
Azure Pipeline
 |
 +-- Build
 +-- Test
 +-- Package
 |
 v
Azure Function

28. Azure DevOps + AKS

For containerized microservices:

Developer
    |
    v
Azure Repos
    |
    v
Azure Pipeline
    |
    +-- Build .NET
    +-- Test
    +-- Docker Build
    +-- Push Image
    |
    v
Azure Container Registry
    |
    v
AKS

This connects several Azure services you should know as a .NET Lead.


29. Docker + Azure DevOps

Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base

WORKDIR /app

EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build

WORKDIR /src

COPY . .

RUN dotnet restore

RUN dotnet publish \
    -c Release \
    -o /app/publish

FROM base AS final

WORKDIR /app

COPY --from=build /app/publish .

ENTRYPOINT ["dotnet", "OrderApi.dll"]

Pipeline:

Code
 ↓
Build
 ↓
Docker Image
 ↓
ACR
 ↓
AKS

30. Azure Container Registry

ACR stores container images.

Azure DevOps
      |
      v
docker build
      |
      v
Docker Image
      |
      v
Azure Container Registry
      |
      v
AKS

Example image:

mycompany.azurecr.io/order-api:1.0.0

31. Infrastructure as Code

A Lead should know that infrastructure shouldn't always be manually created in the Azure Portal.

Use:

Bicep
ARM templates
Terraform

Conceptually:

Infrastructure Code
       |
       v
Azure DevOps Pipeline
       |
       v
Azure Resources

Example:

Bicep
 ↓
App Service
 ↓
SQL
 ↓
Service Bus
 ↓
Key Vault
 ↓
Application Insights

This gives you repeatable environments.


32. Deployment Strategies

You should know these concepts.

Blue-Green

Production
    |
 +-- Blue
 |
 +-- Green

Deploy to Green and switch traffic when validated.


Canary

Users
 |
 +---- 95% → Version 1
 |
 +---- 5%  → Version 2

Monitor Version 2.

If healthy:

5%
 ↓
25%
 ↓
50%
 ↓
100%

Rolling

Gradually replace old instances with new ones.

These strategies are particularly relevant to App Service, AKS and modern deployment architectures.


33. CI/CD Security

Your pipeline should include:

Code
 ↓
Build
 ↓
Unit Tests
 ↓
Security Scan
 ↓
Dependency Scan
 ↓
Quality Checks
 ↓
Artifact
 ↓
Deployment

A Lead should think about:

  • Secret management

  • Least privilege

  • Service connections

  • Branch policies

  • Dependency vulnerabilities

  • Container image scanning

  • Approval controls

  • Audit logs


34. Service Connections

Azure DevOps needs permission to deploy to Azure.

Conceptually:

Azure DevOps
     |
     | Service Connection
     v
Azure Subscription
     |
     +---- App Service
     +---- Function
     +---- ACR
     +---- AKS

Use appropriate identity-based authentication and least privilege rather than broadly granting excessive permissions.


35. Self-Hosted vs Microsoft-Hosted Agents

Microsoft-hosted agent

Azure DevOps provides the machine.

Pipeline
   |
   v
Microsoft-hosted Agent

Advantages:

  • Easy setup

  • Clean environment

  • Microsoft-managed infrastructure

Self-hosted agent

Your organization manages the agent.

Pipeline
   |
   v
Company Agent

Useful when you need:

  • Private network access

  • Special software

  • Internal systems

  • Custom build environments


36. Azure DevOps + Private Network

Suppose your SQL server is private:

Azure DevOps
     |
     X
Public Internet

You may need an appropriate self-hosted agent/network architecture.

Azure DevOps
     |
     v
Self-hosted Agent
     |
     v
VNet
     |
     v
Private SQL

This is an excellent Lead-level scenario.


37. Azure DevOps + Application Insights

You can connect deployment and monitoring:

Azure DevOps
     |
     v
Deploy
     |
     v
App Service
     |
     v
Application Insights
     |
     v
Azure Monitor

Suppose deployment happens:

Version 1.2.0

Then Application Insights shows:

Error rate
   ↑
Latency
   ↑

The Lead can investigate whether the new release caused the regression.


38. Production Deployment Strategy

I would recommend:

Developer
   |
   v
Feature Branch
   |
   v
Pull Request
   |
   +-- Reviewer Approval
   +-- Build Validation
   +-- Unit Tests
   |
   v
main
   |
   v
CI Pipeline
   |
   v
Artifact
   |
   v
DEV
   |
   v
Automated Tests
   |
   v
QA
   |
   v
UAT
   |
   v
Production Approval
   |
   v
PROD
   |
   v
Application Insights

39. Important Lead-Level Principle

Build Once, Deploy Many

Don't do:

Build → DEV
Build → QA
Build → PROD

Instead:

Build
  |
  v
Artifact
  |
  +---- DEV
  |
  +---- QA
  |
  +---- PROD

The same artifact should progress through environments.

This reduces "works in QA but not in production" problems caused by different builds.


40. Another Important Principle — Shift Left

Testing shouldn't start only in production.

You want:

Developer
   ↓
Compile
   ↓
Unit Test
   ↓
Static Analysis
   ↓
Security Scan
   ↓
Integration Test
   ↓
Deploy

The earlier you detect a defect, the cheaper it is to fix.


41. Rollback

Suppose:

Version 2.0

is deployed and causes:

HTTP 500 ↑
Latency ↑
Exceptions ↑

A good pipeline should support rollback.

Conceptually:

Production
   |
   v
Version 2.0
   |
   X
Problem
   |
   v
Rollback
   |
   v
Version 1.9

But a mature deployment strategy also aims to make rollback safe with database migration compatibility and backward-compatible contracts.


42. Database Migration Problem

Suppose:

Application v2

requires:

NewColumn

You can't blindly rollback if the database migration has destroyed compatibility.

Use an approach such as:

Expand
   ↓
Deploy
   ↓
Migrate data
   ↓
Switch application
   ↓
Contract

This is an important Lead-level DevOps + architecture topic.


43. Azure DevOps vs GitHub Actions

You may be asked this.

Both support CI/CD.

Azure DevOps offers a broader suite:

Boards
Repos
Pipelines
Test Plans
Artifacts

GitHub combines source control, collaboration and Actions-based automation in a different platform model.

Lead answer:

"I don't choose solely based on tool popularity. I consider existing organizational tooling, source-control platform, enterprise governance, security, integrations, team expertise and deployment requirements."


44. Azure DevOps Interview Questions

Basic

  1. What is Azure DevOps?

  2. What is Azure Repos?

  3. What is Azure Boards?

  4. What is Azure Pipelines?

  5. What is Azure Artifacts?

  6. What is Azure Test Plans?

  7. What is Git?

  8. What is a Pull Request?

  9. What is CI?

  10. What is CD?


45. Intermediate Questions

  1. Explain a CI/CD pipeline.

  2. What is a build artifact?

  3. What is a pipeline agent?

  4. Microsoft-hosted vs self-hosted agent?

  5. What are environments?

  6. How do you configure DEV/QA/PROD?

  7. How do you handle secrets?

  8. What is a variable group?

  9. What are service connections?

  10. How do you implement approvals?

  11. What are branch policies?

  12. How do you implement rollback?

  13. How do you deploy .NET applications?

  14. How do you deploy Azure Functions?

  15. How do you deploy Docker containers to AKS?


46. Lead-Level Questions

Q26. Design CI/CD for a microservices application.

You should draw:

Git
 ↓
PR
 ↓
Build
 ↓
Test
 ↓
Security
 ↓
Artifact
 ↓
ACR
 ↓
AKS
 ↓
Application Insights

Q27. How would you secure the pipeline?

Answer:

"I would use least-privilege service connections, managed identities where supported, Key Vault for secrets, branch protection, PR approvals, secret scanning, dependency and container scanning, environment approvals, audit logging and separation of duties."


Q28. How would you implement zero-downtime deployment?

Discuss:

Blue/Green
Canary
Rolling deployment
Health checks
Backward-compatible DB changes
Monitoring
Rollback

Q29. How would you handle a failed production deployment?

Strong answer:

Detect
 ↓
Stop further rollout
 ↓
Check Application Insights
 ↓
Compare deployment version
 ↓
Determine impact
 ↓
Rollback / forward fix
 ↓
Verify health
 ↓
Root Cause Analysis
 ↓
Improve pipeline

Q30. How would you design a pipeline for 20 microservices?

Don't necessarily create one giant pipeline.

Consider:

             Shared Templates
                    |
       +------------+------------+
       |            |            |
       v            v            v
 Order Pipeline  Payment       Inventory
       |          Pipeline       Pipeline
       v            v            v
      ACR          ACR           ACR
       |            |             |
       v            v             v
      AKS          AKS           AKS

Use reusable YAML templates and standard pipeline conventions.


47. Real-Time .NET Lead Example

Let's put everything together.

Your company has:

Angular
ASP.NET Core
Azure SQL
Service Bus
Azure Functions
AKS
Key Vault
Application Insights

The delivery architecture:

                      Developer
                          |
                          v
                    Azure Repos
                          |
                          v
                    Pull Request
                          |
                 +--------+--------+
                 |                 |
                 v                 v
              Review         Build Validation
                                   |
                                   v
                              Azure Pipeline
                                   |
               +-------------------+-------------------+
               |                   |                   |
               v                   v                   v
             Build              Unit Test          Security
               |                   |                   |
               +-------------------+-------------------+
                                   |
                                   v
                              Docker Build
                                   |
                                   v
                         Azure Container Registry
                                   |
                                   v
                                  AKS
                                   |
                                   v
                          Application Insights
                                   |
                                   v
                            Azure Monitor

This is a very strong architecture to explain in a Lead interview.


48. What Would I Say in the Interview?

If asked:

"Explain how you have used Azure DevOps in your project."

You can answer:

"We used Azure Repos for Git-based source control and Azure Boards for Agile work management. Developers worked on feature branches and created pull requests with mandatory reviews and build validation. Azure Pipelines implemented CI/CD. The CI stage restored dependencies, built the .NET solution, executed unit tests and security/quality checks, and published an immutable artifact. Deployment stages promoted the same artifact through DEV, QA, UAT and Production with environment-specific configuration and approvals. Secrets were managed through Key Vault, and production deployments were monitored through Application Insights and Azure Monitor. For containerized services, the pipeline built Docker images, pushed them to Azure Container Registry and deployed them to AKS."

That's a strong .NET Lead-level answer.


49. One Diagram to Memorize

For your interview, remember this:

                         AZURE DEVOPS
                              |
       +----------------------+----------------------+
       |                      |                      |
       v                      v                      v
    BOARDS                  REPOS                PIPELINES
       |                      |                      |
    Stories                 Git                 Build
    Tasks                   PR                  Test
    Bugs                    Review              Package
       |                      |                  Deploy
       +----------------------+----------------------+
                              |
                              v
                           Artifact
                              |
                +-------------+-------------+
                |             |             |
                v             v             v
               DEV           QA            PROD
                                             |
                                             v
                                    Application Insights
                                             |
                                             v
                                       Azure Monitor

The 10 things I recommend mastering for your Lead interview

  1. Git + Branching Strategy

  2. Pull Requests + Branch Policies

  3. CI/CD

  4. YAML Pipelines

  5. Build Artifacts

  6. Multi-stage deployment

  7. Environment approvals

  8. Key Vault + Secret Management

  9. Docker + ACR + AKS deployment

  10. Application Insights + Azure Monitor integration


Thursday, June 25, 2026

Top 100 C# Interview Questions and Answers for 2026

 

Introduction

C# (C-Sharp) is one of the most popular programming languages used for building desktop applications, web applications, APIs, cloud solutions, mobile apps, and enterprise software. If you're preparing for a C# developer interview, these frequently asked questions will help you strengthen your fundamentals and advanced concepts.


Basic C# Interview Questions

1. What is C#?

C# is an object-oriented programming language developed by Microsoft for building applications on the .NET platform.

2. What are the key features of C#?

  • Object-Oriented

  • Type-Safe

  • Automatic Garbage Collection

  • Rich Library Support

  • Language Interoperability

  • Scalability

3. What is .NET?

.NET is a software development framework created by Microsoft for building and running applications.

4. What is CLR?

CLR (Common Language Runtime) is the execution engine of .NET that manages memory, exceptions, and security.

5. What is CTS?

CTS (Common Type System) defines how data types are declared and used in .NET.

6. What is CLS?

CLS (Common Language Specification) defines rules that .NET languages must follow to ensure interoperability.

7. What is managed code?

Code executed under CLR supervision.

8. What is unmanaged code?

Code executed directly by the operating system without CLR.

9. What is JIT Compiler?

Just-In-Time Compiler converts Intermediate Language (IL) into machine code at runtime.

10. What is MSIL?

Microsoft Intermediate Language generated after compiling C# code.


OOP Concepts

11. What is Object-Oriented Programming?

A programming paradigm based on objects and classes.

12. What are the four pillars of OOP?

  • Encapsulation

  • Inheritance

  • Polymorphism

  • Abstraction

13. What is a Class?

A blueprint for creating objects.

14. What is an Object?

An instance of a class.

15. What is Encapsulation?

Binding data and methods together while restricting direct access.

16. What is Inheritance?

The ability to derive a class from another class.

17. What is Polymorphism?

The ability of a method to perform different tasks based on context.

18. What is Abstraction?

Hiding implementation details and exposing only essential functionality.

19. What is Method Overloading?

Multiple methods with the same name but different parameters.

20. What is Method Overriding?

Providing a new implementation of a base class method.


Data Types

21. What are Value Types?

Stored directly in memory.

Examples:

  • int

  • double

  • bool

  • char

22. What are Reference Types?

Store references to memory locations.

Examples:

  • class

  • string

  • object

  • array

23. Difference between Value Type and Reference Type?

Value types store actual data, reference types store memory addresses.

24. What is Boxing?

Converting a value type into an object type.

25. What is Unboxing?

Converting an object type back into a value type.

26. What is Nullable Type?

Allows value types to store null values.

Example:

int? age = null;

27. What is var?

Allows implicit type declaration.

28. What is dynamic?

Type checking occurs at runtime.

29. Difference between var and dynamic?

var is checked at compile time, dynamic at runtime.

30. What is object data type?

Base type for all .NET types.


Exception Handling

31. What is Exception Handling?

Mechanism to handle runtime errors.

32. What are try, catch, and finally blocks?

Used to detect and handle exceptions.

33. What is throw keyword?

Used to raise an exception manually.

34. What is custom exception?

User-defined exception class.

35. Difference between throw and throw ex?

throw preserves stack trace; throw ex resets it.


Access Modifiers

36. What are access modifiers?

Keywords controlling visibility.

37. What is public?

Accessible from anywhere.

38. What is private?

Accessible only within the class.

39. What is protected?

Accessible within derived classes.

40. What is internal?

Accessible within the same assembly.


Constructors and Destructors

41. What is a Constructor?

Special method called when an object is created.

42. Types of Constructors?

  • Default

  • Parameterized

  • Static

  • Copy

43. What is Static Constructor?

Executes only once per class.

44. Can constructors be overloaded?

Yes.

45. What is Destructor?

Used for cleanup before object destruction.


Collections

46. What is Array?

Fixed-size collection of elements.

47. What is ArrayList?

Dynamic collection storing any type.

48. What is List?

Generic dynamic collection.

49. Difference between Array and List?

List can grow dynamically.

50. What is Dictionary?

Stores key-value pairs.

51. What is Hashtable?

Non-generic key-value collection.

52. Difference between Dictionary and Hashtable?

Dictionary is generic and type-safe.

53. What is Queue?

FIFO collection.

54. What is Stack?

LIFO collection.

55. What is HashSet?

Stores unique values only.


String Handling

56. Is string a value type or reference type?

Reference type.

57. What is StringBuilder?

Used for efficient string manipulation.

58. Difference between String and StringBuilder?

String is immutable; StringBuilder is mutable.

59. What is string interpolation?

Embedding expressions inside strings.

Example:

$"Hello {name}"

60. What is verbatim string?

String prefixed with @.


Delegates and Events

61. What is Delegate?

Type-safe function pointer.

62. What are Events?

Mechanism for notification.

63. Difference between Delegate and Event?

Events provide controlled delegate access.

64. What is Action Delegate?

Represents methods returning void.

65. What is Func Delegate?

Represents methods returning a value.


LINQ

66. What is LINQ?

Language Integrated Query for querying collections.

67. Benefits of LINQ?

  • Readability

  • Less Code

  • Strong Typing

68. What is Lambda Expression?

Anonymous function syntax.

Example:

x => x > 10

69. What is Deferred Execution?

Query executes only when results are requested.

70. Difference between IEnumerable and IQueryable?

IEnumerable works in memory; IQueryable executes against data source.


Advanced C#

71. What is Interface?

Contract containing method declarations.

72. Can an interface contain implementation?

Yes, using default interface methods in newer versions.

73. What is Abstract Class?

Class that cannot be instantiated directly.

74. Difference between Interface and Abstract Class?

Interfaces define contracts; abstract classes can provide implementation.

75. Can a class inherit multiple classes?

No.

76. Can a class implement multiple interfaces?

Yes.

77. What is Sealed Class?

Class that cannot be inherited.

78. What is Partial Class?

Class definition split across multiple files.

79. What is Extension Method?

Adds methods to existing types.

80. What is Reflection?

Ability to inspect metadata at runtime.


Memory Management

81. What is Garbage Collection?

Automatic memory cleanup process.

82. What are Generations in GC?

  • Generation 0

  • Generation 1

  • Generation 2

83. What is IDisposable?

Interface for releasing unmanaged resources.

84. What is using statement?

Ensures resource disposal.

85. What is Finalize method?

Called by GC before object removal.


Multithreading

86. What is Thread?

Smallest execution unit.

87. What is Multithreading?

Running multiple threads simultaneously.

88. What is Task?

Higher-level abstraction for asynchronous work.

89. What is async and await?

Keywords for asynchronous programming.

90. Difference between Thread and Task?

Tasks are lightweight and managed by the thread pool.


ASP.NET and .NET Core

91. What is ASP.NET?

Framework for web applications.

92. What is ASP.NET Core?

Cross-platform web framework.

93. What is Middleware?

Component that processes HTTP requests.

94. What is Dependency Injection?

Technique for providing dependencies externally.

95. What is REST API?

Architectural style for web services.


Modern C# Features

96. What are Records?

Reference types designed for immutable data.

97. What is Pattern Matching?

Feature for checking object structure and type.

98. What is Nullable Reference Type?

Helps prevent null reference exceptions.

99. What is Global Using?

Allows project-wide namespace imports.

100. What are Top-Level Statements?

Enable writing simple programs without a Program class.


Conclusion

These Top 100 C# Interview Questions cover fundamentals, OOP concepts, collections, LINQ, delegates, multithreading, memory management, ASP.NET Core, and modern C# features. Mastering these questions will significantly improve your confidence in technical interviews for Junior, Mid-Level, and Senior C# Developer positions.

Saturday, October 18, 2025

🚀 Deployment Slots in CI/CD Pipelines — Complete Guide

 🌐 What Are Deployment Slots?

Deployment Slots are live environments within an Azure App Service (Web App) that let you deploy, test, and swap applications without downtime.

Think of them as separate versions of your app running under the same App Service Plan — for example:

  • Production Slot – your live application

  • Staging Slot – where new code is deployed and tested

  • Testing / QA Slot – for internal validation

💡 In short: Deployment slots allow safe, zero-downtime deployments by letting you deploy new versions to a staging environment first and then swap them into production.


🧩 Example Slot Setup

Slot NamePurposeURL Example
ProductionLive user traffichttps://myapp.azurewebsites.net
StagingTest new releases before going livehttps://myapp-staging.azurewebsites.net
QAInternal testinghttps://myapp-qa.azurewebsites.net

Each slot:

  • Has its own configuration (connection strings, app settings)

  • Runs under the same compute resources

  • Can be swapped instantly


⚙️ How Deployment Slots Work in CI/CD

In a CI/CD pipeline, deployment slots are used between the Build and Release stages.

Let’s visualize the flow:

🔁 Pipeline Flow Example

Developer Commit → Build Pipeline → Create Artifact → Deploy to Staging Slot → Validate Tests → Swap to Production Slot

🔹 Step-by-Step Explanation

  1. Build Stage

    • Your code is compiled and tested.

    • Output is packaged as an artifact.

  2. Release Stage

    • The artifact is deployed to the staging slot (not production yet).

    • Automated smoke tests or manual validations are performed.

  3. Slot Swap

    • Once validated, the staging slot is swapped with the production slot.

    • The swap is instantaneous, so users experience zero downtime.

  4. Rollback (if needed)

    • If something goes wrong, simply swap back — instant rollback.


🧱 Example: YAML CI/CD Pipeline Using Deployment Slots

trigger: - main stages: - stage: Build jobs: - job: BuildApp steps: - task: DotNetCoreCLI@2 inputs: command: 'publish' projects: '**/*.csproj' arguments: '--output $(Build.ArtifactStagingDirectory)' - publish: $(Build.ArtifactStagingDirectory) artifact: drop - stage: Deploy dependsOn: Build jobs: - deployment: DeployToStaging environment: 'staging' strategy: runOnce: deploy: steps: - download: current artifact: drop - task: AzureWebApp@1 inputs: azureSubscription: 'MyAzureConnection' appName: 'myapp-service' package: '$(Pipeline.Workspace)/drop/**/*.zip' slotName: 'staging' - deployment: SwapToProduction dependsOn: DeployToStaging steps: - task: AzureAppServiceManage@0 inputs: azureSubscription: 'MyAzureConnection' Action: 'Swap Slots' WebAppName: 'myapp-service' SourceSlot: 'staging' ResourceGroupName: 'MyResourceGroup'

✅ In this pipeline:

  • The Build stage publishes artifacts.

  • The Deploy stage deploys to staging.

  • The Swap step promotes the app to production after verification.


🧠 Key Benefits of Deployment Slots

BenefitDescription
Zero-Downtime DeploymentSwap instantly between slots with no downtime.
Safe TestingTest new versions in staging with production-like settings.
Instant RollbackSwap back to previous slot in seconds if issues occur.
Configuration IsolationDifferent connection strings or keys per slot.
Warm-Up Before ReleaseStaging slot can “preload” your app before swap.

🔍 Use Cases

  1. Blue-Green Deployments
    Deploy new code to blue (staging), swap with green (production) once validated.

  2. Canary Releases
    Gradually route small portions of traffic to the staging slot to monitor impact.

  3. Testing in Production Environment
    Test the latest build in a real environment before it goes live.

  4. Instant Rollback Scenarios
    When a new release fails, swap back to restore the previous version.


⚠️ Things to Keep in Mind

  • Slots share App Service Plan (CPU/RAM).

  • App settings marked as “Slot specific” won’t transfer on swap.

  • Swapping doesn’t move custom domain or SSL settings (they stay on production).

  • Limit: Free and Shared App Service Plans do not support slots.


🧰 Integration with Azure DevOps

In Azure DevOps, you can use:

  • Azure Web App Deploy Task to deploy to specific slots

  • Azure App Service Manage Task to perform swap operations

  • Environments for approvals before swapping to production

This allows controlled, automated deployments without affecting live traffic.


🏁 Summary Table

FeatureDescription
Deployment SlotSeparate environment within App Service
Common SlotsProduction, Staging, QA
Supported PlansStandard, Premium, Isolated
Swap OperationMoves staging → production instantly
CI/CD IntegrationAzure DevOps Pipelines, GitHub Actions, or CLI

💬 Final Thought

Deployment slots are one of the most effective DevOps strategies for achieving:

  • Zero downtime

  • Safe testing in production

  • Quick rollback in case of failure

🗣️ “If you’re deploying to Azure App Service, deployment slots are your safety net for continuous delivery.”

🚀 Understanding CI/CD Pipeline: From Local Repository to Deployment

 🌐 Introduction to CI/CD Pipeline

In modern software development, Continuous Integration (CI) and Continuous Deployment (CD) are the backbone of DevOps practices.
They help teams deliver high-quality software faster, reliably, and automatically.

  • Continuous Integration (CI) focuses on automating the build and testing process whenever code is pushed to a repository.

  • Continuous Deployment (CD) focuses on automatically releasing the tested code to different environments such as staging or production.

A well-defined CI/CD pipeline ensures that every change in code goes through an automated and repeatable process — reducing errors, saving time, and improving code quality.


🧩 Major Stages in a CI/CD Pipeline

Here’s how a typical CI/CD process flows from the developer’s local repository to final production deployment:

1. Code Commit (Local Repository Stage)

  • The developer writes and tests code locally.

  • Once tested, the developer commits the code to a Version Control System (VCS) like Git.

  • Example:

    git add . git commit -m "Added user login API" git push origin main

🧠 This step ensures that your code is versioned, traceable, and ready for integration.


2. Source Control & Remote Repository

  • The pushed code is stored in a remote repository such as GitHub, GitLab, or Bitbucket.

  • This repository acts as a central hub for the team, where all code changes are merged and reviewed.

🔍 Example:

  • GitHub repository: https://github.com/username/myproject

  • Branch strategy: main, develop, feature/*, release/*


3. Continuous Integration (CI) Process

Once code is pushed, the CI system (like Jenkins, Azure DevOps, or GitHub Actions) triggers an automated build and test pipeline.

Typical CI Steps:

  1. Code Checkout: Fetch code from the repository.

  2. Build Application: Compile the source code.

  3. Run Unit Tests: Verify code functionality.

  4. Static Code Analysis: Check code quality (using SonarQube, ESLint, etc.).

  5. Package Artifacts: Build deployable units (e.g., .zip, .jar, .dll, or Docker image).

Example (Azure DevOps YAML):

trigger: branches: include: - main pool: vmImage: 'ubuntu-latest' steps: - checkout: self - script: dotnet build MyApp.sln displayName: 'Build Application' - script: dotnet test MyApp.Tests/MyApp.Tests.csproj displayName: 'Run Unit Tests'

4. Artifact Storage

After successful CI, the output (build artifacts) is stored in an artifact repository or container registry:

  • Azure Artifacts

  • JFrog Artifactory

  • Docker Hub

🧩 Example:
A .zip build file or Docker image like myapp:v1.0.0 is stored for deployment.


5. Continuous Deployment (CD) Process

Once the build artifacts are ready, the CD process handles automated deployment to testing, staging, or production environments.

CD Steps Include:

  1. Deploy to Test Environment

  2. Run Integration Tests / UI Tests

  3. Approval Gates (Manual/Automatic)

  4. Deploy to Production

Example (Azure DevOps Release Pipeline):

  • Stage 1: Deploy to Staging App Service

  • Stage 2: Approval by QA

  • Stage 3: Deploy to Production App Service

🧠 Tip: You can also use Infrastructure as Code (IaC) tools like Terraform or ARM Templates to automate infrastructure setup.


6. Monitoring and Feedback

After deployment, the system is continuously monitored using:

  • Azure Application Insights

  • Prometheus + Grafana

  • New Relic

If any issue is detected, alerts are triggered, and teams can roll back to a stable build.


⚙️ Example CI/CD Workflow: .NET Core + Angular App on Azure

Let’s consider an example scenario:

StageTool UsedDescription
Code DevelopmentVisual Studio / VS CodeDeveloper codes locally
Version ControlGitHubPush code to main branch
CI BuildAzure PipelinesBuild .NET Core API and Angular app
Artifact StorageAzure ArtifactsStore build outputs
CD ReleaseAzure App ServicesDeploy app to staging → production
MonitoringApplication InsightsMonitor performance and logs

💡 Pipeline Summary

Local Machine → GitHub → Azure DevOps CI → Azure Artifact → Azure DevOps CD → Azure App Service (Production)

✅ Benefits of Implementing CI/CD

  • 🚀 Faster Delivery: Automates build, test, and deploy processes.

  • 🧠 Improved Code Quality: Automated tests ensure stable builds.

  • 🔄 Quick Rollbacks: Easily revert to previous versions.

  • 💼 Better Collaboration: Developers can integrate code frequently.

  • 🕵️ Early Bug Detection: CI helps identify issues early in the cycle.


🔍 Conclusion

Implementing a CI/CD pipeline transforms traditional development into a modern DevOps workflow.
From committing code locally to automated deployment, each step ensures speed, reliability, and efficiency.

Whether you use Azure DevOps, GitHub Actions, GitLab CI, or Jenkins, the goal remains the same — deliver quality software faster with minimal human effort.

Don't Copy

Protected by Copyscape Online Plagiarism Checker