This project provides hands-on labs to learn Rust, C#, Containers, Azure Kubernetes Service (AKS), and advanced Kubernetes features like autoscaling and message queues.
Build and deploy basic REST APIs to AKS.
- Rust API - Built with Actix-web framework
- C# API - Built with ASP.NET Core Minimal API
- Infrastructure - Bicep templates for ACR and AKS
- Deployment - Kubernetes manifests and deployment pipelines
π View Lab 1 Guide
Extend the Rust API with asynchronous message processing using RabbitMQ and auto-scaling worker services.
- Message Queue - RabbitMQ for async task processing
- Rust API Enhancement - POST
/sendendpoint to publish messages - C# Worker Service - Scalable message consumer with simulated processing
- Horizontal Pod Autoscaler (HPA) - Automatic worker scaling based on CPU load
- Testing Scripts - PowerShell tools for load testing and monitoring
π View Lab 2 Guide
π HPA Reference Documentation
Both APIs are containerized and ready for deployment to Azure Kubernetes Service (AKS).
Lab 1: Start here to set up the basic infrastructure and APIs.
Lab 2: Build on Lab 1 to add message queuing and autoscaling capabilities.
βββ src/
β βββ RustKubernetesDemo.sln
β βββ rust-api/ # Rust REST API (Lab 1 & 2)
β β βββ src/
β β β βββ main.rs
β β βββ Cargo.toml
β β βββ Dockerfile
β βββ csharp-api/ # C# REST API (Lab 1)
β β βββ Program.cs
β β βββ HelloApi.csproj
β β βββ Dockerfile
β βββ worker-service/ # C# Worker Service (Lab 2)
β β βββ WorkerService/
β β βββ Worker.cs
β β βββ Program.cs
β β βββ WorkerService.csproj
β β βββ Dockerfile
β βββ k8s/ # Kubernetes manifests
β β βββ namespace.yaml
β β βββ rust-deployment.yaml
β β βββ csharp-deployment.yaml
β β βββ rabbitmq-deployment.yaml # Lab 2
β β βββ worker-deployment.yaml # Lab 2
β β βββ worker-hpa.yaml # Lab 2
β βββ infra/ # Azure infrastructure (Bicep)
β βββ main.bicep
βββ .build/ # Build automation scripts
β βββ Build-All.ps1
βββ .deploy/ # Deployment & monitoring scripts (Lab 2)
β βββ Deploy-AKS.ps1
β βββ Deploy-Local.ps1
β βββ Validate-Deployment.ps1
β βββ Get-ProcessingResults.ps1
β βββ Monitor-Queue.ps1
β βββ Watch-HPA.ps1
βββ .test/ # Testing & validation scripts (Lab 2)
β βββ Send-TestMessages.ps1
β βββ Test-E2E.ps1
β βββ Test-HPAScaling.ps1
βββ docs/ # Lab guides and documentation
β βββ LabExperimentGuide.md # Lab 1 Guide
β βββ Lab2-MessageQueue.md # Lab 2 Guide
β βββ HPA-Reference.md # HPA Deep Dive
βββ docker-compose.yml # Local development (Lab 2)
βββ README.md
The following tools are required for development and deployment:
| Tool | Purpose | Required For |
|---|---|---|
| WSL 2 | Linux environment on Windows | Docker Desktop (Windows) |
| Docker Desktop | Container runtime | Building & running containers |
| Visual Studio Build Tools | C++ compiler and linker | Rust development (Windows) |
| Rust | Rust API development | Local development |
| .NET 10 SDK | C# API development | Local development |
| Azure CLI | Azure resource management | Azure deployment |
| kubectl | Kubernetes management | AKS deployment |
WSL 2 is required for Docker Desktop on Windows.
-
Open PowerShell as Administrator and run:
wsl --install -
Restart your computer
-
After restart, set WSL 2 as the default version:
wsl --set-default-version 2
-
Verify installation:
wsl --version
Note: Windows 10 version 2004+ (Build 19041+) or Windows 11 is required for WSL 2.
-
Download from Docker Desktop
-
Run the installer and follow the prompts
-
Restart your computer if prompted
-
Verify installation:
docker --version docker run hello-world
Visual Studio Build Tools provides the MSVC compiler and linker required for Rust development on Windows.
- Download Visual Studio Build Tools
- Run the installer
- Select "Desktop development with C++" workload
- Click Install and wait for completion
- Restart your computer
Note: This is different from VS Code. The Build Tools provide the C++ compiler toolchain needed by Rust.
Windows:
-
Download and run rustup-init.exe
-
Follow the on-screen instructions (default installation is recommended)
-
Restart your terminal
-
Verify installation:
rustc --version cargo --version
macOS/Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustc --versionWindows:
-
Download from .NET 10 SDK
-
Run the installer
-
Verify installation:
dotnet --version
macOS (using Homebrew):
brew install dotnet@10
dotnet --versionLinux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install -y dotnet-sdk-10.0
dotnet --versionWindows:
-
Download and run the Azure CLI MSI installer
-
Verify installation:
az --version
macOS:
brew install azure-cli
az --versionLinux:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az --versionWindows (using winget):
winget install Kubernetes.kubectl
kubectl version --clientWindows (using Chocolatey):
choco install kubernetes-cli
kubectl version --clientmacOS:
brew install kubectl
kubectl version --clientLinux:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --clientTip: If you have Docker Desktop installed, kubectl is included. Enable it in Docker Desktop > Settings > Kubernetes > Enable Kubernetes.
cd src/rust-api
cargo run
# API runs on http://localhost:8080cd src/csharp-api
dotnet run
# API runs on http://localhost:8080# Build Rust API
docker build -t hello-rust-api:latest ./src/rust-api
# Build C# API
docker build -t hello-csharp-api:latest ./src/csharp-api# Run Rust API
docker run -p 8080:8080 hello-rust-api:latest
# Run C# API (use different host port to avoid conflict)
docker run -p 8081:8080 hello-csharp-api:latestOnce the APIs are running (either via cargo run/dotnet run or Docker), test them with curl:
Rust API (port 8080):
# Hello endpoint
curl http://localhost:8080/
# Health check
curl http://localhost:8080/health
# API info
curl http://localhost:8080/infoC# API (port 8080 local, or 8081 if running both in Docker):
# Hello endpoint
curl http://localhost:8080/
# Health check
curl http://localhost:8080/health
# API info
curl http://localhost:8080/infoTip: Use
| ConvertTo-Jsonfor formatted output:Invoke-RestMethod -Uri http://localhost:8080/ | ConvertTo-Json
Note: ACR names must be globally unique and contain only lowercase letters and numbers (5-50 characters).
# Login to Azure
az login
# Create resource group
az group create --name rg-hello-apis --location eastus
# Deploy infrastructure using Bicep (replace acrhelloapis12345 with a unique name)
az deployment group create `
--resource-group rg-hello-apis `
--template-file src/infra/main.bicep `
--parameters clusterName=aks-hello-apis acrName=acrhelloapis12345# Login to ACR
az acr login --name acrhelloapis12345
# Tag and push images
docker tag hello-rust-api:latest acrhelloapis12345.azurecr.io/hello-rust-api:latest
docker tag hello-csharp-api:latest acrhelloapis12345.azurecr.io/hello-csharp-api:latest
docker push acrhelloapis12345.azurecr.io/hello-rust-api:latest
docker push acrhelloapis12345.azurecr.io/hello-csharp-api:latest# Get AKS credentials
az aks get-credentials --resource-group rg-hello-apis --name aks-hello-apis
# Update image names in k8s manifests to use your ACR
# Then apply manifests
kubectl apply -f src/k8s/namespace.yaml
kubectl apply -f src/k8s/rust-deployment.yaml
kubectl apply -f src/k8s/csharp-deployment.yaml# Get service IPs
kubectl get services -n hello-apis
# Test endpoints
curl http://<RUST_EXTERNAL_IP>/
curl http://<RUST_EXTERNAL_IP>/health
curl http://<CSHARP_EXTERNAL_IP>/
curl http://<CSHARP_EXTERNAL_IP>/healthBoth Rust and C# APIs expose the same endpoints:
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Returns "Hello, World!" message |
/health |
GET | Health check endpoint |
/info |
GET | Returns API information |
The Rust API gains an additional endpoint in Lab 2:
| Endpoint | Method | Description |
|---|---|---|
/send |
POST | Publishes a message to RabbitMQ queue |
Example Request:
{
"task_type": "process-data",
"payload": {
"data": "your data here"
}
}- Build REST APIs in Rust and C#
- Containerize applications with Docker
- Deploy to Azure Kubernetes Service
- Manage infrastructure with Bicep
- Configure Kubernetes resources
- Implement asynchronous message processing
- Use RabbitMQ for message queuing
- Build background worker services
- Configure Horizontal Pod Autoscaler (HPA)
- Monitor and test distributed systems
- Create operational automation scripts
- Uses Managed Identity for AKS to ACR authentication
- Non-root containers
- Resource limits defined in Kubernetes manifests
- Health checks configured for liveness and readiness probes