Showing posts with label Docker. Show all posts
Showing posts with label Docker. 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.

Monday, June 29, 2026

Complete Guide to Docker with Real-Time Example (Beginner to Advanced)

Complete Guide to Docker with Real-Time Example (Beginner to Advanced)

Category: DevOps | Docker | Containers | Cloud Computing

Level: Beginner to Advanced

Reading Time: 35–45 Minutes


Table of Contents

  1. Introduction

  2. What is Docker?

  3. Why Do We Need Docker?

  4. Virtual Machines vs Docker

  5. Docker Architecture

  6. Docker Components

  7. Installing Docker

  8. Docker Images

  9. Docker Containers

  10. Dockerfile

  11. Docker Volumes

  12. Docker Networks

  13. Docker Compose

  14. Docker Registry

  15. Docker Hub

  16. Dockerizing an ASP.NET Core Application

  17. Docker Commands

  18. Real-Time Enterprise Example

  19. Docker Best Practices

  20. Common Mistakes

  21. Docker Interview Questions

  22. Advantages and Disadvantages

  23. Conclusion


Introduction

Modern software development requires applications to run consistently across development, testing, staging, and production environments. One of the biggest challenges developers face is the classic problem:

"It works on my machine."

Different operating systems, library versions, and configurations can cause applications to behave differently in each environment.

Docker solves this problem by packaging an application together with all its dependencies into a lightweight, portable unit called a container.

Whether you're building an ASP.NET Core Web API, an Angular application, or a microservices platform, Docker makes deployment faster, more reliable, and consistent.


What is Docker?

Docker is an open-source containerization platform that allows developers to package applications and their dependencies into isolated containers.

A Docker container contains:

  • Application source code

  • Runtime

  • Libraries

  • Frameworks

  • Configuration files

  • System tools

This ensures the application behaves the same regardless of where it is deployed.


Why Do We Need Docker?

Imagine you're developing an ASP.NET Core application.

On your machine:

  • .NET SDK 9

  • SQL Server

  • Redis

  • RabbitMQ

Everything works.

You deploy the application to another server.

Problems appear:

  • Different .NET version

  • Missing libraries

  • Different OS

  • Configuration mismatch

Docker packages everything together.

Result:

Developer Laptop

↓

Docker Image

↓

QA Server

↓

Production

↓

Cloud

The application behaves identically in every environment.


Traditional Deployment vs Docker

Traditional Deployment

Application

↓

Operating System

↓

Physical Server

Problems:

  • Dependency conflicts

  • Difficult upgrades

  • Environment inconsistency

  • Slow deployments


Docker Deployment

Application

↓

Docker Container

↓

Docker Engine

↓

Operating System

↓

Server

Benefits:

  • Fast startup

  • Lightweight

  • Portable

  • Isolated

  • Easy scaling


Virtual Machines vs Docker

FeatureVirtual MachineDocker
Boot TimeMinutesSeconds
SizeGBsMBs
PerformanceSlowerFaster
OSFull Guest OSShares Host OS Kernel
Resource UsageHighLow
PortabilityModerateHigh

Docker Architecture

graph TD

Developer --> DockerCLI

DockerCLI --> DockerEngine

DockerEngine --> Images

DockerEngine --> Containers

DockerEngine --> Volumes

DockerEngine --> Networks

DockerEngine --> DockerHub

Docker Components

Docker Client

The Docker CLI (docker) used to interact with Docker Engine.

Example:

docker ps
docker images
docker run

Docker Engine

The core service responsible for:

  • Building images

  • Running containers

  • Managing networks

  • Managing volumes


Docker Images

A Docker image is a read-only template used to create containers.

Think of it as a blueprint.

Example:

ASP.NET Core Image

↓

Container 1

Container 2

Container 3

Docker Containers

A running instance of an image.

Multiple containers can be created from the same image.

Example:

Image

↓

Container A

Container B

Container C

Docker Registry

A repository used to store Docker images.

Popular registries:

  • Docker Hub

  • Azure Container Registry (ACR)

  • Amazon Elastic Container Registry (ECR)

  • Google Artifact Registry (GAR)


Installing Docker

Supported operating systems:

  • Windows

  • Linux

  • macOS

Verify installation:

docker --version

Example output:

Docker version 28.x.x

Docker Images

Download an image:

docker pull nginx

View images:

docker images

Remove an image:

docker rmi nginx

Docker Containers

Run an Nginx container:

docker run nginx

Run in detached mode:

docker run -d nginx

Run with a custom name:

docker run --name webapp nginx

Map a port:

docker run -d -p 8080:80 nginx

List running containers:

docker ps

List all containers:

docker ps -a

Stop a container:

docker stop webapp

Remove a container:

docker rm webapp

Dockerfile

A Dockerfile contains instructions for building an image.

Example for an ASP.NET Core Web API:

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

WORKDIR /src

COPY . .

RUN dotnet restore

RUN dotnet publish -c Release -o /app

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

WORKDIR /app

COPY --from=build /app .

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

Build the image:

docker build -t employee-api .

Run the image:

docker run -d -p 5000:8080 employee-api

Docker Volumes

Containers are ephemeral. Data stored inside a container is lost when it is removed.

Volumes provide persistent storage.

Create a volume:

docker volume create employee-volume

Run SQL Server with a volume:

docker run -d \
-e ACCEPT_EULA=Y \
-e SA_PASSWORD=Password@123 \
-v employee-volume:/var/opt/mssql \
-p 1433:1433 \
mcr.microsoft.com/mssql/server:2022-latest

Docker Networks

Networks allow containers to communicate securely.

Create a network:

docker network create employee-network

Run containers on the same network:

docker run -d --network employee-network redis
docker run -d --network employee-network employee-api

Docker Compose

Docker Compose manages multi-container applications.

Example:

version: '3.9'

services:

  api:
    build: .
    ports:
      - "5000:8080"

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2022-latest
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "Password@123"

  redis:
    image: redis

Start services:

docker compose up -d

Stop services:

docker compose down

Docker Hub

Docker Hub is the default public registry.

Upload an image:

docker login

docker tag employee-api username/employee-api:v1

docker push username/employee-api:v1

Dockerizing an ASP.NET Core Application

Project structure:

EmployeeAPI

├── Controllers
├── Models
├── Dockerfile
├── Program.cs
├── appsettings.json
└── EmployeeAPI.csproj

Steps:

  1. Create a Dockerfile.

  2. Build the Docker image.

  3. Run the container.

  4. Verify the API using a browser or Postman.

  5. Push the image to Docker Hub or Azure Container Registry.


Common Docker Commands

CommandDescription
docker imagesList images
docker psRunning containers
docker ps -aAll containers
docker buildBuild image
docker runRun container
docker stopStop container
docker startStart container
docker restartRestart container
docker logsView logs
docker exec -itOpen a shell in a container
docker rmRemove container
docker rmiRemove image
docker compose upStart multi-container app
docker compose downStop multi-container app

Real-Time Enterprise Example

Imagine an online shopping application built with microservices.

Architecture:

Internet
      │
Load Balancer
      │
─────────────────────────────────────
│        │         │         │
Frontend Product  Order   Payment
Angular   API      API      API
─────────────────────────────────────
      │
─────────────────────────────────────
│         │            │
SQL Server Redis     RabbitMQ
─────────────────────────────────────

Each service runs in its own Docker container.

Benefits:

  • Independent deployments

  • Easy scaling

  • Fault isolation

  • Consistent environments

  • Simplified updates

This architecture is commonly used in enterprise applications before orchestrating the containers with Kubernetes.


Docker Best Practices

  • Use official base images whenever possible.

  • Keep images as small as possible.

  • Use multi-stage builds to reduce image size.

  • Avoid running containers as the root user.

  • Use .dockerignore to exclude unnecessary files.

  • Store secrets outside the image using environment variables or secret management solutions.

  • Tag images with version numbers instead of relying on latest.

  • Clean up unused images and containers regularly.

  • Scan images for vulnerabilities before deployment.

  • Keep base images updated with security patches.


Common Mistakes Beginners Make

  • Using the latest tag in production.

  • Creating unnecessarily large images.

  • Storing secrets inside Dockerfiles.

  • Running multiple unrelated applications in a single container.

  • Ignoring persistent storage requirements.

  • Not exposing the correct ports.

  • Forgetting to use .dockerignore.

  • Leaving unused containers and images on the host.


Docker Interview Questions

1. What is Docker?

Docker is a platform for building, packaging, distributing, and running applications in lightweight containers.

2. What is the difference between an image and a container?

An image is a read-only template. A container is a running instance of that image.

3. What is a Dockerfile?

A Dockerfile is a text file containing instructions used to build a Docker image.

4. What is Docker Compose?

Docker Compose is a tool for defining and managing multi-container applications using a YAML file.

5. What is a Docker volume?

A Docker volume provides persistent storage that exists independently of the container lifecycle.

6. What is the purpose of a Docker network?

It enables secure communication between containers and isolates application traffic.

7. What is Docker Hub?

Docker Hub is a public registry for storing and sharing Docker images.

8. Why use multi-stage builds?

They reduce the final image size by excluding build tools and intermediate artifacts.

9. How is Docker different from a virtual machine?

Docker shares the host operating system kernel, making containers smaller, faster, and more efficient than virtual machines.

10. Can Docker be used with Kubernetes?

Yes. Docker is used to build container images, while Kubernetes orchestrates and manages containers at scale. (Modern Kubernetes uses OCI-compatible container runtimes, so Docker-built images work seamlessly.)


Advantages

  • Fast deployment

  • Lightweight containers

  • Portable across environments

  • Efficient resource usage

  • Simplified CI/CD integration

  • Easy scaling

  • Consistent deployments

  • Excellent support for microservices


Disadvantages

  • Containers share the host kernel, which may not suit every workload.

  • Requires good security practices for production.

  • Persistent data management needs careful planning.

  • Networking can become complex in large environments.

  • Learning container orchestration (e.g., Kubernetes) adds complexity.


Conclusion

Docker has transformed modern software development by enabling developers to package applications with everything they need into portable, lightweight containers. It eliminates environment inconsistencies, accelerates deployments, simplifies testing, and integrates seamlessly with CI/CD pipelines and cloud platforms.

Whether you're developing an ASP.NET Core Web API, an Angular application, or a microservices-based enterprise solution, Docker is a foundational DevOps skill. Once you're comfortable with Docker, the natural next step is learning Kubernetes to orchestrate containers at scale and build highly available, production-ready cloud-native applications.



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.

Monday, September 15, 2025

🚀 Azure Cloud Services Benefits – A Complete Guide for Modern Applications

Cloud adoption has become the backbone of modern businesses, and Microsoft Azure stands out as one of the most powerful cloud platforms. Whether you’re building a simple website or a complex enterprise-grade microservices application, Azure provides everything from identity management to DevOps-ready container orchestration.

In this article, let’s explore how Azure works step by step, its benefits, and how you can use it with .NET Core backend + Angular frontend applications.


🔑 1. User Creation, Groups & Permissions (Azure Active Directory)

Every cloud journey starts with identity and access management. In Azure, this is handled by Azure Active Directory (Azure AD).

✅ How It Works

  • User Creation: Admins can create users in Azure AD (manual entry, bulk import, or synced from on-premises AD).

  • Groups: Users can be organized into groups (e.g., Developers, Testers, Admins).

  • Permissions (Role-Based Access Control - RBAC): Instead of assigning permissions to individuals, you assign them to groups or roles (e.g., Contributor, Reader, Owner).

  • Single Sign-On (SSO): One login can access Azure Portal, Microsoft 365, and custom business apps.

👉 Example:

  • A developer group can get “Contributor” rights to deploy apps.

  • A tester group can get “Reader” rights to monitor apps but not make changes.

This ensures security, compliance, and streamlined management.


🌐 2. Hosting in Azure (Web Apps & App Services)

Azure makes application hosting simple and scalable with Azure App Services.

✅ Benefits

  • Host .NET Core APIs and Angular UI with minimal configuration.

  • Automatic scaling (based on traffic).

  • Continuous Deployment from GitHub, Azure DevOps, or local machine.

  • Built-in monitoring and logging.

👉 Example:

  • Host your .NET Core Web API in one App Service.

  • Deploy your Angular UI as a Static Web App or in the same App Service.


🐳 3. Containers with Docker

For teams adopting DevOps and portability, Docker on Azure is a game-changer.

✅ How It Works

  • Docker Images: Package your app (.NET API + Angular frontend) into lightweight containers.

  • Azure Container Registry (ACR): Store your private Docker images.

  • Azure App Service for Containers: Run Docker containers directly without managing infrastructure.

👉 Example:
Instead of worrying about server OS and dependencies, you just push your Docker image to ACR and run it.


☸️ 4. Kubernetes with Azure Kubernetes Service (AKS)

When applications grow and need scalability, high availability, and microservices, AKS (Azure Kubernetes Service) is the right choice.

✅ Benefits

  • Automates container orchestration (deployment, scaling, self-healing).

  • Load balances traffic between microservices.

  • Integrates with Azure Monitor and Azure DevOps for CI/CD.

  • Secure communication with Azure AD + RBAC.

👉 Example:
Your .NET Core APIs (User Service, Order Service, Payment Service) run as separate containers. Angular frontend consumes these APIs. Kubernetes ensures uptime even if one container crashes.


📩 5. Messaging with Azure Service Bus

Modern apps often need asynchronous communication between services. That’s where Azure Service Bus helps.

✅ Benefits

  • Decouples microservices with queues and topics.

  • Reliable delivery of messages, even during downtime.

  • Supports FIFO (First-In-First-Out) and pub/sub messaging.

👉 Example:

  • When a user places an order, the Order Service publishes a message to Service Bus.

  • Payment Service and Inventory Service consume the message independently.

This makes your app more resilient and scalable.


🧩 6. Microservices Architecture in Azure

Azure supports building microservices-based applications using:

  • AKS (Kubernetes) for orchestration.

  • Azure Service Bus for communication.

  • Azure API Management for unified API gateway.

  • Cosmos DB / SQL Server for data storage.

👉 Example Setup:

  • Authentication Service – Validates users via Azure AD.

  • Order Service – Handles order logic.

  • Payment Service – Processes payments.

  • Notification Service – Sends email/SMS updates.

Each service runs independently in containers, communicates via Service Bus, and scales individually.


💻 7. .NET + Angular on Azure

One of the most common enterprise stacks is .NET Core backend + Angular frontend, and Azure provides full support.

✅ Typical Workflow

  1. Develop your .NET Core Web APIs.

  2. Build your Angular UI.

  3. Containerize both apps with Docker.

  4. Push images to Azure Container Registry.

  5. Deploy via AKS (Kubernetes) or App Services.

  6. Secure with Azure AD authentication.

  7. Use Azure DevOps CI/CD pipelines for automated builds & deployments.

👉 Example CI/CD Flow:

  • Code pushed to GitHub → Azure DevOps pipeline builds Docker images → Images stored in ACR → AKS auto-deploys latest containers → Angular app fetches API data.


🎯 Final Thoughts

Azure Cloud Services provide end-to-end solutions for hosting, security, scalability, and modern app development. Whether you’re a startup building a simple web app or an enterprise handling millions of transactions, Azure gives you:

  • Identity & Security with Azure AD

  • Reliable Hosting with App Services

  • Portability with Docker

  • Scalability with Kubernetes

  • Asynchronous Messaging with Service Bus

  • Modern Architecture with Microservices

  • Seamless Development with .NET + Angular + DevOps

If you’re moving your apps to the cloud, Azure is not just an option – it’s a complete ecosystem for growth and innovation. 🚀



Don't Copy

Protected by Copyscape Online Plagiarism Checker