Virtual machines, containers and functions compared
What actually differs between a virtual machine, a container and a function: what each one virtualises, how strong its isolation is, how fast it starts, and which of them can bill you nothing while nothing is happening.
Lesson 3 of 11 in objective architecture-and-services. Azure architecture and services, part of Microsoft Certified: Azure Fundamentals (AZ-900).
Virtual machines virtualise the hardware
A virtual machine is a computer that happens to be software: it boots its own operating system, and everything above the hypervisor is yours to install, configure and patch. That is the trade in one sentence. You get compatibility with anything — a kernel-level driver, a registry-editing scheduled task, a runtime that went out of support years ago — and in exchange you own the operating system for as long as the machine exists.
This is why lift and shift lands on virtual machines. Read a requirements list for anything BELOW the application, and each item is an argument for infrastructure as a service, because no higher-level option will let you reach down there.
Containers virtualise the operating system
A container image carries an application and its dependencies, and containers on a host share that host's operating system kernel rather than each booting one. Every visible property follows from that single fact: they start in seconds because there is no operating system to boot, they pack densely because there is no per-instance kernel reserving memory, and their isolation is weaker than a virtual machine's because the kernel they share is a boundary they have in common.
Azure offers two ways to run them and the split between the two is examinable. Azure Container Instances runs a container with no orchestrator for you to operate — burst capacity, a batch job, one isolated task. Azure Kubernetes Service is the managed orchestrator: Azure runs the control plane, you run the workloads, and what you get for the extra operational surface is scheduling, self-healing, rolling upgrades and service discovery. Containers change the packaging; they do not answer the question of how many replicas to run, which is still yours or an autoscaler's.
Functions remove the server from view
Azure Functions runs a piece of code when something happens. The trigger can be an incoming HTTP request, but it can equally be a timer, a message arriving on a queue, a new blob in a container, or an event published by another service — and treating HTTP as the only trigger is the misconception the exam checks for. Serverless in Azure means three things at once: no infrastructure for you to manage, scaling driven automatically by demand, and billing tied to executions rather than to uptime.
That third property is the discriminator, and it is worth over-weighting when reading a stem. A workload that is event-driven, short-lived and idle most of the time costs almost nothing on a consumption plan and costs a full day's billing on a virtual machine sized for its busiest hour. When a question describes bursty work and then mentions paying for what is used, it has already told you the answer.
Reading the scenario
Three phrases decide most of these. Anything below the application — drivers, the registry, an unsupported runtime, a required patch level — means a virtual machine. Packaging with dependencies, conflicting library versions, fast start-up and density mean containers, with the orchestration vocabulary deciding which of the two container services. Event-driven, intermittent, and paying only for what runs means Functions. Everything else in the option list is usually a real Azure service placed one level away from where it belongs.
Worth carrying in
- Virtual machine
- Infrastructure as a service. Its own guest operating system, which you patch.
- Container
- Application plus dependencies, sharing the host kernel. Seconds to start.
- Container image
- The packaged, portable artefact a container is started from.
- Azure Container Instances
- Run a container with no orchestrator to operate.
- Azure Kubernetes Service
- Managed orchestration: scheduling, self-healing, rolling upgrades, service discovery.
- Azure Functions
- Code started by a trigger, billed per execution, scaling to nothing when idle.
- Trigger
- What starts a function: HTTP, a timer, a queue message, a new blob, an event.
- Serverless
- No infrastructure to manage, automatic scaling, and billing by execution.
What the exam does with this
- Containers do not boot a kernel — they share the host's. Any option claiming a container isolates as strongly as a virtual machine gets there through a kernel that does not exist.
- "Pay only when it runs" and "idle most of the time" point at Functions. The billing model is the discriminator, not the scaling.
- HTTP is one trigger among many. An option restricting Functions to web requests is testing whether you know timers, queues and blobs also start them.
- Container Instances against Kubernetes Service is decided by the orchestration vocabulary in the stem: scheduling, self-healing, rolling upgrades, service discovery.
- An availability set is not a compute type. It appears in this option list anyway, and it is a placement construct for virtual machines.
- Objective
- architecture-and-services. Azure architecture and services
- Share of the exam
- 38.46% (the whole objective)
- Questions in this lesson
- 4
- Signed for by a person
- 0
Partly checked. None of the 4 questions here has been read against the cited source by a person. 4 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
Questions in this lesson
- An image-resizing routine runs for about two seconds whenever a file lands in a storage container — perhaps two hundred times on a busy day, and not at all on a quiet one. The team wants to pay for the work done and maintain no servers. Which compute option fits? machine-checked
- A fifteen-year-old accounting application needs a kernel-level driver, a scheduled task that edits the registry, and a runtime version nobody supports any more. The business wants it running in Azure this quarter with as few code changes as possible. Where does it go? machine-checked
- A team runs nine small services, each with its own conflicting library versions. They want each one packaged with its dependencies, starting in seconds, several to a host, without a separate operating system per service. Which compute type are they describing? machine-checked
- Which TWO of these statements about Azure compute types are true? machine-checked
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Virtual machines, containers and functions compared
The rest of objective architecture-and-services
- Regions, region pairs, availability zones and datacentres
- Resources, resource groups, subscriptions and management groups
- Virtual machines, containers and functions compared — you are here
- Virtual machine options, and what a virtual machine needs
- Hosting an application: web apps, containers and virtual machines
- Virtual networks, subnets, peering and Azure DNS
- Reaching Azure privately: VPN Gateway, ExpressRoute and endpoints
- Storage accounts, storage services, tiers and redundancy
- Moving files and migrating workloads into Azure
- Microsoft Entra ID, authentication and role-based access control
- Zero Trust, defence in depth and Defender for Cloud