Chapter 6 of 21
Azure Compute Building Blocks: VMs, Containers, and Serverless
Tour the main compute options in Azure—from virtual machines to containers to serverless functions—and see when each one shines in real solutions.
Orienting Yourself: Azure Compute in the Big Picture
Where Compute Fits
Every Azure solution needs compute. Your main choices are virtual machines, containers, and serverless. Each fits differently with IaaS, PaaS, and serverless models.
Link to Service Models
VMs are classic IaaS: you get virtualized servers, storage, networking on demand. Container platforms and serverless functions sit closer to PaaS.
Regions and Resources
Compute resources run in Azure regions and Availability Zones. They are Azure resources inside resource groups and subscriptions, and their placement impacts resilience.
Exam Mindset
AZ-900 questions often describe a scenario and ask you to choose VMs, containers, or serverless. This module trains that pattern-recognition skill.
Azure Virtual Machines: Your IaaS Building Block
What Is an Azure VM?
An Azure VM is a virtual server in the cloud. You choose Windows or Linux, size, disks, and networking, and you manage what happens inside the OS.
What You Control
You install patches, configure firewalls, add runtime frameworks, and deploy apps. This flexibility is powerful but increases your management effort.
When VMs Fit Best
Use VMs for legacy apps, software that needs specific drivers, or when you must control the OS and security stack in detail.
Exam Signal Words
Phrases like "lift-and-shift", "full control of OS", or "custom security software" usually point toward choosing Azure Virtual Machines.
Scaling and Availability for VMs: Availability Sets, Zones, and Scale Sets
Why One VM Is Not Enough
A single VM is a single point of failure. Azure offers availability sets, Availability Zones, and VM scale sets to improve resilience and scale.
Availability Sets
Availability sets spread VMs across fault and update domains, reducing impact from host failures and planned maintenance in a single region.
Availability Zones
Availability Zones are separate datacenter locations in a region. Placing VMs in different zones protects against an entire zone outage.
VM Scale Sets
VM scale sets manage groups of identical VMs and support autoscaling based on metrics like CPU or request count.
Example: Choosing VM Availability Options
Scenario Overview
An online ordering system moves to Azure. Two web servers and a database must be highly available and handle traffic spikes.
Designing the Web Tier
Use a VM scale set for web servers, spread instances across multiple Availability Zones, and front them with a load balancer or Application Gateway.
Handling the Database
Use a managed PaaS database with zone redundancy, or, if self-managed, deploy database VMs with availability and zone awareness.
Link to Exam Clues
Host failure → availability set. Datacenter/zone failure → Availability Zones. Autoscaling VMs → VM scale set.
Containers and Azure Kubernetes Service (AKS): High-Level View
What Is a Container?
A container bundles an app and its dependencies into a portable unit. It shares the host OS kernel, so it is lighter than a VM.
Key Azure Container Services
Azure Container Registry stores images. Azure Container Instances runs containers directly. Azure Kubernetes Service orchestrates containers at scale.
AKS in a Nutshell
AKS is a managed Kubernetes service. Azure manages the control plane; you manage worker nodes and your containerized applications.
When Containers Fit
Think containers for microservices, portability, and when you need orchestration features like rolling updates and autoscaling.
Serverless with Azure Functions: Code Without Servers
What Is Serverless?
Serverless means you run code without managing servers. Azure still uses servers, but you do not see or administer them.
Azure Functions Basics
Azure Functions let you write small pieces of code that run when triggered by events like HTTP calls, queue messages, or timers.
Benefits and Use Cases
You get automatic scaling and pay-per-execution pricing. Use Functions for APIs, background jobs, and integration glue between services.
Exam Clues
Phrases like "event-driven", "pay only when code runs", or "no server management" usually point to Azure Functions.
Comparing VMs, Containers, and Serverless in a Real Scenario
Photo App Scenario
A startup builds a photo-sharing app with a web front-end, upload API, and background image processing. How should they host each part?
All on VMs
Separate Azure VMs host the front-end, API, and worker. This gives full control but requires OS management and more scaling work.
Containers on AKS
All components become containers in AKS. This suits microservices and portability, but needs Kubernetes skills and cluster operations.
Serverless and PaaS Mix
App Service hosts the front-end, Azure Functions host the API and background processing. This minimizes infrastructure work and scales automatically.
Thought Exercise: Match Workloads to Compute Options
Work through these short thought exercises. Answer in your head or jot down choices; then compare to the suggested reasoning.
- Legacy ERP system
- Requirements: Runs on Windows Server 2012 with a custom driver. Vendor does not support containers. Needs OS-level antivirus and monitoring agents.
- Best fit: Azure Virtual Machines.
- Why: Needs specific OS and drivers plus full OS control.
- Event-driven data processing
- Requirements: When a CSV file is uploaded to Blob Storage, parse it and write data into a database. Usage is spiky; some hours see no uploads.
- Best fit: Azure Functions.
- Why: Event-driven, pay-per-execution, no servers to manage.
- Microservices-based e-commerce platform
- Requirements: Dozens of small services, independent deployment, rolling updates, traffic spikes during sales. Team already uses Docker and Kubernetes on-prem.
- Best fit: Azure Kubernetes Service (AKS).
- Why: Container orchestration at scale, matches existing skills.
- Internal line-of-business web app
- Requirements: Simple .NET web app, predictable traffic, no need for OS-level tweaks. Team wants to minimize ops.
- Best fit: Likely Azure App Service (PaaS web apps), which sits between VMs and serverless.
Reflect: In each case, what words pushed you toward IaaS, PaaS, containers, or serverless? This is the same reasoning you will use on AZ-900 scenario questions.
Quick Check: Compute Model Basics
Test your understanding of when to use VMs, containers, or serverless.
A company wants to run existing Docker-based microservices in Azure with rolling updates, service discovery, and autoscaling. They have Kubernetes experience and want to keep using it. Which Azure compute option is the best fit?
- Azure Virtual Machines in an availability set
- Azure Kubernetes Service (AKS)
- Azure Functions in the Consumption plan
- Azure App Service (Web Apps)
Show Answer
Answer: B) Azure Kubernetes Service (AKS)
AKS is designed to run and orchestrate containerized applications using Kubernetes. It supports rolling updates, autoscaling, and service discovery. VMs alone lack orchestration; Functions are for event-driven serverless code, not full microservice platforms; App Service runs web apps but does not provide full Kubernetes-style microservice orchestration.
Quick Check: Availability and Serverless
Another short question to reinforce availability and serverless concepts.
You are designing a solution that should process messages from a queue. The load is highly variable, and the business wants to pay only when processing occurs, without managing servers. Which option best meets these requirements?
- Azure Virtual Machines in a Virtual Machine Scale Set
- Azure Kubernetes Service running a containerized worker
- Azure Functions triggered by the queue
- A single large Azure Virtual Machine
Show Answer
Answer: C) Azure Functions triggered by the queue
Azure Functions with a queue trigger are ideal for event-driven workloads with variable load and pay-per-execution pricing. VM scale sets and AKS still require you to manage infrastructure and pay for provisioned capacity; a single large VM is the least flexible and will be underutilized when the queue is empty.
Flashcards: Key Terms and Concepts
Use these flashcards to reinforce core compute vocabulary and exam-ready distinctions.
- Azure Virtual Machine (VM)
- An IaaS compute resource in Azure that provides a virtualized server (Windows or Linux) where you manage the operating system, runtime, and applications.
- Availability set
- A logical grouping of VMs that distributes them across fault domains and update domains within a datacenter to reduce the impact of hardware failures and planned maintenance.
- Availability Zone
- A physically separate location within an Azure region, with independent power, cooling, and networking. Deploying resources across zones increases resilience to datacenter-level failures.
- Virtual Machine Scale Set (VMSS)
- An Azure compute resource that lets you deploy and manage a set of identical, autoscaling VMs as a single resource, often used for stateless workloads.
- Container
- A lightweight, portable unit that packages an application and its dependencies, sharing the host OS kernel and enabling consistent execution across environments.
- Azure Kubernetes Service (AKS)
- A managed Kubernetes service in Azure where Microsoft manages the control plane while you manage worker nodes and containerized applications, enabling orchestration, scaling, and rolling updates.
- Azure Functions
- A serverless compute service in Azure that lets you run event-driven code without managing servers, scaling automatically and often billed per execution and resource consumption.
- Event-driven architecture
- A design pattern where components communicate by producing and consuming events, well-suited to serverless compute like Azure Functions and services like Event Grid or Service Bus.
- When to choose VMs vs. serverless
- Choose VMs when you need full OS control, custom drivers, or legacy app support. Choose serverless when you want minimal infrastructure management, event-driven execution, and pay-per-use.
- When to choose containers/AKS vs. VMs
- Choose containers/AKS when you have microservices, need portability and orchestration features, and can manage container platforms. Choose VMs when apps are not container-ready or need OS-level customization.
Key Terms
- Container
- A lightweight, portable unit that packages an application and its dependencies together and shares the host operating system kernel, enabling consistent execution across environments.
- Azure Functions
- A serverless compute service in Azure that runs event-driven code without requiring you to provision or manage servers, scaling automatically and often billed per execution.
- Availability set
- A logical grouping of VMs that distributes them across fault domains and update domains within a datacenter to reduce the impact of hardware failures and planned maintenance.
- Availability Zone
- A physically separate location within an Azure region, with independent power, cooling, and networking, designed to increase resilience to datacenter-level failures when resources are spread across zones.
- Serverless compute
- A cloud execution model where the cloud provider dynamically manages the allocation of compute resources, and you are billed based on actual usage rather than pre-provisioned capacity.
- Event-driven architecture
- A software design pattern in which components communicate by producing and consuming events, enabling loosely coupled and scalable systems, often implemented using serverless and messaging services.
- Azure Virtual Machine (VM)
- An Infrastructure as a Service (IaaS) compute resource in Azure that provides a virtualized server where you manage the operating system, runtime, and applications.
- Azure Container Registry (ACR)
- A managed, private Docker registry service in Azure for storing and managing container images used by Azure container runtimes such as AKS and Azure Container Instances.
- Azure Kubernetes Service (AKS)
- A managed Kubernetes service in Azure where Microsoft manages the control plane and you manage worker nodes and containerized applications, enabling container orchestration at scale.
- Virtual Machine Scale Set (VMSS)
- An Azure compute resource that lets you deploy and manage a set of identical, autoscaling virtual machines as a single resource.