Azure Deployment
Deploy HypLab to Microsoft Azure using AKS, Container Instances, or Virtual Machines.
Azure Deployment
This guide covers deploying HypLab to Microsoft Azure using AKS (Kubernetes), Container Instances, or Virtual Machines.
Prerequisites
- Azure account
- Azure CLI installed and configured
- kubectl (for AKS)
- Docker
- Domain name
Option 1: AKS (Kubernetes)
Step 1: Create Resource Group
az group create --name hyplab-rg --location eastusStep 2: Create AKS Cluster
az aks create \
--resource-group hyplab-rg \
--name hyplab-cluster \
--node-count 3 \
--node-vm-size Standard_B2s \
--enable-cluster-autoscaler \
--min-count 2 \
--max-count 5 \
--enable-addons monitoring \
--generate-ssh-keysStep 3: Configure kubectl
az aks get-credentials --resource-group hyplab-rg --name hyplab-clusterStep 4: Deploy HypLab
Follow the Kubernetes Deployment Guide using your AKS cluster.
Step 5: Configure Azure Services
Cosmos DB (MongoDB API)
Note: For MongoDB, use MongoDB Atlas or self-host. Cosmos DB MongoDB API has compatibility limitations.
Azure Cache for Redis
# Create Redis cache
az redis create \
--resource-group hyplab-rg \
--name hyplab-redis \
--location eastus \
--sku Basic \
--vm-size c0Get connection details:
az redis show --name hyplab-redis --resource-group hyplab-rg --query hostName
az redis list-keys --name hyplab-redis --resource-group hyplab-rgOption 2: Container Instances
Step 1: Create Container Registry
# Create ACR
az acr create \
--resource-group hyplab-rg \
--name hyplabregistry \
--sku Basic
# Login
az acr login --name hyplabregistry
# Build and push
az acr build --registry hyplabregistry --image api:latest api/
az acr build --registry hyplabregistry --image app:latest app/Step 2: Create Container Group
az container create \
--resource-group hyplab-rg \
--name api \
--image hyplabregistry.azurecr.io/api:latest \
--registry-login-server hyplabregistry.azurecr.io \
--registry-username $(az acr credential show --name hyplabregistry --query username -o tsv) \
--registry-password $(az acr credential show --name hyplabregistry --query passwords[0].value -o tsv) \
--dns-name-label api \
--ports 4096 \
--environment-variables NODE_ENV=production \
--secure-environment-variables \
MONGODB_URL="mongodb+srv://..." \
REDIS_URL="redis://..." \
--cpu 2 \
--memory 4Step 3: Get Public IP
az container show \
--resource-group hyplab-rg \
--name api \
--query ipAddress.fqdnOption 3: Virtual Machines
Step 1: Create VM
# Create VM
az vm create \
--resource-group hyplab-rg \
--name hyplab-vm \
--image Ubuntu2204 \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-sku Standard
# Open ports
az vm open-port --port 80 --resource-group hyplab-rg --name hyplab-vm
az vm open-port --port 443 --resource-group hyplab-rg --name hyplab-vmStep 2: Install Docker
SSH into VM:
ssh azureuser@<public-ip>Install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USERStep 3: Deploy with Docker Compose
Follow Docker Production Deployment.
Azure Services Configuration
Key Vault (Secrets)
Store secrets in Key Vault:
# Create Key Vault
az keyvault create \
--name hyplab-vault \
--resource-group hyplab-rg \
--location eastus
# Store secrets
az keyvault secret set \
--vault-name hyplab-vault \
--name mongodb-url \
--value "mongodb+srv://..."
az keyvault secret set \
--vault-name hyplab-vault \
--name redis-url \
--value "redis://..."
az keyvault secret set \
--vault-name hyplab-vault \
--name jwt-secret \
--value "your-jwt-secret"Grant access:
az keyvault set-policy \
--name hyplab-vault \
--spn <service-principal-id> \
--secret-permissions get listApplication Insights
Enable Application Insights for monitoring:
# Create Application Insights
az monitor app-insights component create \
--app hyplab-insights \
--location eastus \
--resource-group hyplab-rg
# Get instrumentation key
az monitor app-insights component show \
--app hyplab-insights \
--resource-group hyplab-rg \
--query instrumentationKeyAzure Monitor
View logs and metrics:
- Go to Azure Portal > Monitor
- Create dashboard with:
- Request count
- Response time
- Error rate
- CPU/Memory usage
Application Gateway (Load Balancer)
# Create public IP
az network public-ip create \
--resource-group hyplab-rg \
--name hyplab-pip \
--allocation-method Static \
--sku Standard
# Create Application Gateway
az network application-gateway create \
--resource-group hyplab-rg \
--name hyplab-agw \
--location eastus \
--sku Standard_v2 \
--public-ip-address hyplab-pip \
--subnet <subnet-id> \
--capacity 2SSL/TLS with Application Gateway
Upload SSL Certificate
# Create Key Vault certificate
az keyvault certificate create \
--vault-name hyplab-vault \
--name ssl-cert \
--file certificate.pfx
# Configure Application Gateway with certificate
az network application-gateway ssl-cert create \
--resource-group hyplab-rg \
--gateway-name hyplab-agw \
--name ssl-cert \
--key-vault-secret-id <secret-id>Monitoring & Alerting
Create Alert Rule
az monitor metrics alert create \
--name "High Error Rate" \
--resource-group hyplab-rg \
--scopes <resource-id> \
--condition "avg Percentage CPU > 80" \
--window-size 5m \
--evaluation-frequency 1m \
--action email alerts@yourdomain.comCost Optimization
Use Spot VMs (AKS)
az aks nodepool add \
--resource-group hyplab-rg \
--cluster-name hyplab-cluster \
--name spotpool \
--node-count 2 \
--node-vm-size Standard_B2s \
--priority Spot \
--eviction-policy Delete \
--spot-max-price -1Reserved Instances
Purchase Reserved Instances for predictable workloads (up to 72% savings).
Auto Scaling
Configure auto-scaling:
az aks update \
--resource-group hyplab-rg \
--name hyplab-cluster \
--enable-cluster-autoscaler \
--min-count 2 \
--max-count 5Backup
Azure Backup
# Create Recovery Services Vault
az backup vault create \
--resource-group hyplab-rg \
--name hyplab-backup-vault \
--location eastus
# Enable backup for VM
az backup protection enable-for-vm \
--resource-group hyplab-rg \
--vault-name hyplab-backup-vault \
--vm <vm-id> \
--policy-name DefaultPolicyBlob Storage Backups
# Create storage account
az storage account create \
--name hyplabbackups \
--resource-group hyplab-rg \
--location eastus \
--sku Standard_LRS
# Create container
az storage container create \
--name backups \
--account-name hyplabbackups
# Upload backup
az storage blob upload \
--account-name hyplabbackups \
--container-name backups \
--name backup-$(date +%Y-%m-%d).tar.gz \
--file backup.tar.gzNext Steps
- Kubernetes Deployment - Detailed K8s setup
- Monitoring Setup - Configure observability
- Troubleshooting - Common issues