Skip to main content

Choosing Between Azure VMs, App Service, and AKS

Learn how to choose between Virtual Machines, App Service, and AKS based on control needs, traffic patterns, and operational overhead.

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
Remember

This 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.

flowchart TD Q1{Need OS-level
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

  1. Create a resource group:
Bash
az group create --name rg-compute-decision-central --location centralindia
  1. 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:
Bash
cat > cloud-init-reporting.yaml << 'EOF'
#cloud-config
package_update: true
packages:
- docker.io
runcmd:
- docker run -d --restart always -p 80:80 mcr.microsoft.com/azuredocs/aks-helloworld:v1
EOF
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
  1. Wait a couple of minutes for cloud-init to finish, then call the VM:
Bash
VM_IP=$(az vm show -d --resource-group rg-compute-decision-central \
--name vm-reporting-tool --query publicIps --output tsv)
curl "http://$VM_IP"
  1. Deploy the same image on App Service. There is no OS to manage, and the platform handles the runtime and scaling:
Bash
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"
  1. 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:
Bash
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:v1
kubectl expose deployment reporting-tool --type=LoadBalancer --port=80
kubectl get service reporting-tool --watch
  1. Compare 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.

  2. 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.

  3. Clean up everything at once:

Bash
az group delete --name rg-compute-decision-central --yes --no-wait

Production Best Practices & Common Pitfalls

Common Mistake

Choosing 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.

Tip

Start 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

Explore More in Azure Compute Services

All 6 Topics

Frequently Asked Questions

Is Choosing Between Azure VMs, App Service, and AKS free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Choosing Between Azure VMs, App Service, and AKS topic cover?

Learn how to choose between Virtual Machines, App Service, and AKS based on control needs, traffic patterns, and operational overhead.

Found a mistake, an outdated step or a broken link?