Architecture Flow
Built locally using .NET 8 >> Tested locally to ensure correctness >> Containerized with Docker >> Stored securely in Azure Container Registry >> Deployed to Azure Kubernetes Service >> Automatically updated via GitHub Actions
Required Software
- Visual Studio Code
- .NET 8 SDK
- Git
- Docker Desktop ⚠️ Start Docker Desktop after installation
- Azure CLI
- kubectl
- GitHub CLI (optional but recommended)
✅ Verify Installations
In VS Code, after installation, create a folder for the project and verify these dotnet, git, docker, az , kubectl. Run the following commands:
- dotnet --version
- git --version
- docker --version
- az --version
- kubectl version --client
Step 1: Create and Test the .NET Application Locally
Never deploy untested code. Testing locally allows you to:
- Catch errors early
- Validate endpoints
- Avoid expensive cloud debugging
1.1 Create Project Structure
mkdir weather-app-demo
cd weather-app-demo
mkdir WeatherApp
cd WeatherApp
1.2 Initialize the .NET Web API
we initialize a .NET Web API to get the application ready to receive, process, and respond to HTTP requests correctly. Initialization wires everything together so the Web API can run reliably, securely, and predictably.
dotnet new webapi -minimal
1.3 Add Required Packages
dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks
dotnet add package Swashbuckle.AspNetCore
This package lets us monitor the health of the Web API and its dependencies.
- It check if the API is running
- 🗄️ Verify dependencies like databases, APIs, caches
- 🚦 Expose health endpoints (e.g. /health)
- ☁️ Support cloud platforms (Azure, Kubernetes, load balancers)
We add Swashbuckle to automatically generate interactive API documentation and testing tools.
1.4 Replace Program.cs
1.5 Test Locally
We use dotnet run to build and start a .NET application locally so we can test and run it during development..NET will:
- 🔨 Compile the code (build the project)
- ▶️ Start the application
- 🌐 Launch the Web API / app on a local server (Kestrel)
Test endpoints:
✅ If this works, your app is ready for containerization
🐳 Step 2: Containerize the Application with Docker
We containerise an application to make it run the same way everywhere — on a laptop, server, or in the cloud.
2.1 Create Dockerfile
Create Dockerfile using the command touch dockerfile, then paste the code below.
2.2 Create .dockerignore
We create a .dockerignore file to tell Docker which files and folders NOT to include when building an image. To do that we do touch .dockerignore to create .dockerfile and the paste the code below.
bin/
obj/
.vs/
.vscode/
.git/
.gitignore
Dockerfile
README.md
*.log
2.3 Build and Test Container Locally
_docker build -t weather-app:local .
docker run -p 8080:8080 weather-app:local_
Test again in browser or with curl. ✅ If it works locally, it will work in AKS.
🔧 Step 3: Create Azure Infrastructure
3.1 Login to Azure
_az login _
3.2 Create Resource Group
az group create --name student-demo --location eastus
3.3 Create Azure Container Registry (ACR)
az acr create \
--resource-group student-demo \
--name studentdemoacr \
--sku Basic
3.4 Build & Push Image Using ACR
We do ACR Build:
- To avoids Docker compatibility issues
- Runs inside Azure
- Faster CI/CD later
_az acr build \
--registry studentdemoacr \
--image weather-app:latest _
3.5 Create AKS Cluster with ACR Attached
We do this so AKS can securely pull Docker images from Azure Container Registry (ACR) without extra credentials or manual setup
az aks create \
--resource-group student-demo \
--name student-aks \
--node-count 1 \
--attach-acr studentdemoacr \
--enable-managed-identity \
--generate-ssh-keys
3.6 Connect kubectl to AKS
We connect kubectl to AKS so our local machine can securely communicate with and manage the AKS cluster. Without this connection, you cannot see, deploy, or control anything in the cluster.
az aks get-credentials \
--resource-group student-demo \
--name student-aks
Verify:
kubectl get nodes
☸️ Step 4: Deploy to Kubernetes
4.1 Create Kubernetes Manifests
We create Kubernetes manifests to tell Kubernetes exactly how we want our application to run.Kubernetes doesn’t guess.
Manifests are the instructions + desired state.
mkdir k8s
cd k8s
deployment.yaml
Use touch deployment.yaml to create our deployment yaml file and paste the code.
service.yaml
Use touch service.yaml and paste the code
4.2 Apply Manifests
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
Check status:
kubectl get pods
kubectl get services
🔁 Step 5: CI/CD with GitHub Actions
Why CI/CD? : No manual deployments.Faster releases and. Safer changes
5.1 Initialize Git
git init
git add .
git commit -m "Initial Weather App"
5.2 Create GitHub Repo
Login to your Github
gh auth login
Create a repository
gh repo create weather-app-demo --public --source=. --push
5.3 Create Workflow File
mkdir -p .github/workflows
To create github work flow use
touch .github/workflows/deploy.yml and paste the code below
🌐 Step 6: Access the Application
kubectl get service weather-service
In this project, we successfully built, containerized, and deployed a .NET 8 Web API using modern cloud-native practices on Microsoft Azure. Starting with local development and testing, we ensured application correctness before moving into containerization with Docker for consistency across environments. The container image was securely stored in Azure Container Registry and deployed to Azure Kubernetes Service, enabling scalability, resilience, and production-grade orchestration.
By integrating GitHub Actions, we automated the build and deployment pipeline, ensuring that every code change is safely and consistently delivered to AKS without manual intervention. This end-to-end workflow demonstrates a real-world DevOps lifecycle—combining application development, containerization, infrastructure provisioning, Kubernetes deployment, and CI/CD automation.
Overall, this project highlights best practices for building and deploying cloud-native applications, reinforcing the importance of automation, reliability, and scalability in modern software engineering.





































Top comments (0)