Overview and What You Will Learn
Choose the most managed Azure compute option that still meets the workload's needs: App Service for ordinary web apps, AKS for many coordinated containerized services, and virtual machines only when you need OS-level control. In this lab you will run the same container image on a VM, on App Service and on AKS, and compare how much each one makes you manage.
- Deploying one container image on three compute services
- Comparing setup effort and ongoing responsibility
- Using a decision path from workload needs to service
- Knowing where Azure Container Apps fits between App Service and AKS
RememberThis lab creates a VM, an App Service plan and an AKS cluster, which all bill while they exist. Run it in one sitting and delete the resource group at the end.
Why This Matters in Production
A wrong compute choice rarely fails outright, it just costs engineering time every month for the life of the application. Imagine a team at a company like PhonePe that builds a simple internal reporting tool and runs it on a VM they must patch, monitor and secure forever, when App Service would have run it with no server management and built-in scaling.
Core Principles
Each Azure compute option trades control for operational simplicity, and the right choice depends on what the workload actually needs. Three questions decide it: does the workload need OS-level control or software App Service cannot run, is it one application or many coordinated containerized services, and how much operational work is the team equipped to carry long term.
control?}:::q -->|yes| VM[Virtual Machine]:::tool Q1 -->|no| Q2{Many coordinated
container services?}:::q Q2 -->|yes| AKS[AKS]:::tool Q2 -->|no| APP[App Service]:::ok classDef q fill:#FFEDD5,color:#1E293B classDef tool fill:#326CE5,color:#FFFFFF classDef ok fill:#10B981,color:#FFFFFF
The table below shows who is responsible for what:
| Option | You manage |
|---|---|
| Virtual Machine | OS patching, runtime, process manager, scaling, security |
| App Service | Application code and settings |
| AKS | Containers, Kubernetes configuration, node pools, upgrades |
Detailed Step-by-Step Practical Lab
- Create a resource group:
az group create --name rg-compute-decision-central --location centralindia- Deploy the container on a raw VM. You install Docker, run the container, open the port and keep the OS patched. A cloud-init file automates the first part:
cat > cloud-init-reporting.yaml << 'EOF'#cloud-configpackage_update: truepackages: - docker.ioruncmd: - docker run -d --restart always -p 80:80 mcr.microsoft.com/azuredocs/aks-helloworld:v1EOF az vm create \ --resource-group rg-compute-decision-central \ --name vm-reporting-tool \ --image Ubuntu2204 \ --size Standard_B1s \ --admin-username azureadmin \ --generate-ssh-keys \ --custom-data cloud-init-reporting.yaml az vm open-port \ --resource-group rg-compute-decision-central \ --name vm-reporting-tool \ --port 80- Wait a couple of minutes for cloud-init to finish, then call the VM:
VM_IP=$(az vm show -d --resource-group rg-compute-decision-central \ --name vm-reporting-tool --query publicIps --output tsv)curl "http://$VM_IP"- Deploy the same image on App Service. There is no OS to manage, and the platform handles the runtime and scaling:
az appservice plan create \ --name asp-reporting-tool \ --resource-group rg-compute-decision-central \ --sku B1 \ --is-linux az webapp create \ --resource-group rg-compute-decision-central \ --plan asp-reporting-tool \ --name reporting-tool-rahul \ --deployment-container-image-name mcr.microsoft.com/azuredocs/aks-helloworld:v1 az webapp config appsettings set \ --resource-group rg-compute-decision-central \ --name reporting-tool-rahul \ --settings WEBSITES_PORT=80 APP_HOST=$(az webapp show --resource-group rg-compute-decision-central \ --name reporting-tool-rahul --query defaultHostName --output tsv)curl "https://$APP_HOST"- Deploy the same image on AKS. This creates a cluster, and you then work with Kubernetes objects instead of a server or a single app:
az aks create \ --resource-group rg-compute-decision-central \ --name aks-reporting-tool \ --node-count 1 \ --node-vm-size Standard_B2s \ --generate-ssh-keys az aks get-credentials \ --resource-group rg-compute-decision-central \ --name aks-reporting-tool kubectl create deployment reporting-tool \ --image=mcr.microsoft.com/azuredocs/aks-helloworld:v1kubectl expose deployment reporting-tool --type=LoadBalancer --port=80 kubectl get service reporting-tool --watchCompare what each path asked of you. The VM needed a runtime install, an open port and ongoing OS patching. App Service needed one container setting. AKS needed a cluster, credentials and Kubernetes objects. For a single web application, the extra layers on the VM and AKS paths buy nothing.
Consider when the picture changes. If the reporting tool grew into five interdependent services, such as a frontend, an API, a background worker, a cache and a queue processor, all needing coordinated scaling and service discovery, that is the point where AKS earns its operational cost.
Clean up everything at once:
az group delete --name rg-compute-decision-central --yes --no-waitProduction Best Practices & Common Pitfalls
Common MistakeChoosing AKS by default because it feels more serious or scalable, then spending months on cluster upgrades, node pool sizing and networking for what was really one web application that App Service would have run with far less effort.
TipStart with App Service for any standard web application unless a concrete requirement demands VM-level control. Built-in scaling, deployment slots and zero OS maintenance outweigh a VM's flexibility for most web workloads.
- Choose VMs for a specific need. Legacy software tied to an OS configuration, custom kernel modules, or hardware-level access that App Service and AKS do not expose justify a VM.
- Consider Azure Container Apps for containers without Kubernetes. It runs containerized services with scale-to-zero and built-in ingress, and fits when you need more than one app but not cluster administration.
- Reserve AKS for real orchestration needs. Several interdependent containerized services with coordinated scaling, service discovery and platform-team ownership justify the overhead, not the word "containers" alone.
- Scale VMs with scale sets. A single VM does not scale itself, so use Virtual Machine Scale Sets for load-based scaling.
- Count the people, not just the price. A cheap VM that needs weekly patching can cost more in engineering time than a higher-priced managed service.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
az vm create |
Create a virtual machine with full OS control |
az webapp create |
Create an App Service web app |
az aks create |
Create a managed Kubernetes cluster |
az aks get-credentials |
Configure kubectl for an AKS cluster |
az webapp show --query "state" |
Check whether an App Service is running |