Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 57 ยท Compute

Choosing a Compute Service

Compare Azure Virtual Machines, App Service, Functions, Container Apps, AKS and Batch, learn the trade-offs in cost and operations, and use a decision helper.

Azure gives you many places to run code, and the choice is rarely about what is possible. Almost any workload can run on a virtual machine. The real question is how much of the machine you want to look after. Every step away from a raw VM hands more work to Azure (patching, scaling, load balancing) and takes away some control.

This lesson puts the compute services you met in this chapter side by side, adds two you have not seen yet (Container Apps and Batch, covered later), and gives you a way to decide. The services need an account, so everything about them here is explained in text. The runnable part is a small decision helper written in JavaScript: a stand-in that encodes the rules of thumb so you can see how the answer changes with the requirements.

The control versus convenience scale

Think of a line. On the left you manage almost everything; on the right you only bring code.

flowchart LR
    A["Virtual Machines<br/>you manage the OS"] --> B["AKS<br/>you manage Kubernetes workloads"]
    B --> C["Container Apps<br/>you bring a container"]
    C --> D["App Service<br/>you bring a web app"]
    D --> E["Functions<br/>you bring a function"]

Moving right means less to operate, but fewer knobs to turn. Batch sits beside this line: it runs large groups of jobs.

Here is what each service is for.

Virtual Machines

A virtual machine is a full operating system that you own. You choose the size, install anything, open any port and patch it yourself. Pick a VM when you need software that cannot run elsewhere (legacy installers, special drivers, a custom kernel), when you must control the operating system, or when you are moving an existing server with as few changes as possible (often called "lift and shift"). The cost is operations: patching, backups, hardening and scaling are your job, though scale sets automate the last one.

App Service

App Service runs web apps and APIs. Azure manages the operating system, the runtime (.NET, Java, Node.js, Python, PHP) and the load balancer. You get deployment slots, custom domains, TLS and autoscale as settings. It is usually the fastest route for a conventional web application. The limits are that you work inside its supported runtimes and its sandbox rules, and you pay for the plan whether or not requests arrive.

Azure Functions

Functions run small pieces of code in response to triggers: an HTTP call, a timer, a queue message. On the Consumption or Flex Consumption plans you pay per execution and the platform scales to zero. It suits glue code, webhooks and event processing. It does not suit long, heavy or always-warm workloads, and cold starts can add latency after idle periods.

Container Apps

Azure Container Apps runs containers without making you operate a Kubernetes cluster. It has revisions, built-in ingress, scale rules (including scale to zero) and jobs. It fits microservices, APIs and background workers when you already have a container image.

Azure Kubernetes Service (AKS)

AKS is managed Kubernetes. Azure runs the control plane; you manage node pools, upgrades, networking choices and everything you deploy. Choose it when you need the full Kubernetes API, custom operators, service meshes or portability between clouds, and when you have people who can run it. Without that experience, AKS often becomes the most expensive option in time.

Azure Batch

Batch schedules large numbers of compute jobs across pools of VMs: rendering frames, simulations, nightly processing of millions of files. You submit tasks and Batch finds the machines, runs them and can use low-priority or Spot capacity to cut cost. It is for work that is embarrassingly parallel and finite, not for a web server.

Questions that decide the answer

You rarely need a flowchart with 30 branches. A handful of questions does most of the work.

  1. Does the work run to completion, or does it serve requests all the time? Large finite jobs lean toward Batch. Always-on services lean elsewhere.
  2. Is it triggered by events and short? Functions.
  3. Is it a standard web app or API in a supported language? App Service.
  4. Is it already a container? Container Apps first; AKS if you need Kubernetes itself.
  5. Does it need OS-level control or unsupported software? Virtual Machines.
  6. Can it sit idle for long periods? Prefer something that scales to zero (Functions, Container Apps).

Cost follows the same pattern. VMs and App Service plans charge for reserved capacity by the hour. Functions and Container Apps can charge only while code runs, which is cheap for spiky workloads and not always cheaper for steady ones. Always compare using your real traffic; the formulas are in Pricing, Cost Management and Budgets.

A decision helper

The program below is a stand-in, not an Azure tool. Each requirement is a yes or no flag, and a small rule list picks a service and explains why. Run it and then change the flags to see how the recommendation moves.

JS Compute decision helper

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The ordering of the rules matters. Batch and OS control are checked first because they are strong signals; "web app" is checked last because many things are web apps. A real review would also weigh team skills, compliance and existing contracts, which no flag list can capture. The effort scores at the end are the stand-in author's rough judgment, not an Azure metric.

Migration paths

Choosing is not permanent. Typical moves are:

  • VM to App Service: when the app is a standard web stack and you want to stop patching servers.
  • App Service to Container Apps: when you split a monolith into containers or need scale to zero.
  • Container Apps to AKS: when you outgrow its feature set and have the team to run Kubernetes.
  • Anything to Functions: for individual pieces of event-driven work extracted from a larger app.

You make these moves easier by keeping the application stateless, reading configuration from environment variables, and keeping data in managed services, so the compute choice stays replaceable.

Comparing options with numbers

A decision is stronger with rough numbers. The next stand-in uses made-up prices (they are not real Azure prices) to show the shape of the trade-off: a function billed per million executions against an always-on small instance, as traffic grows.

JS Pay per use versus always on

Press Run (or Ctrl + Enter) to see the console output here.

No output.

With these invented numbers, pay per use wins until about 30 million calls a month, then loses. The break-even point depends on the real prices, memory size and execution time, so always recompute it for your own workload.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A team must run a legacy application that needs a Windows installer and a custom driver. Which service fits best?

    Custom installers and drivers need control of the operating system, which only a virtual machine gives you.
  2. 2. Which workload is the best match for Azure Batch?

    Batch schedules large, finite, parallel jobs across pools of machines. It is not meant for always-on web servers or single-instance databases.
  3. 3. You have a set of containers and want scale to zero without managing a Kubernetes cluster. What is the usual first choice?

    Container Apps runs containers with built-in ingress and scale rules, including scale to zero, and you do not operate the cluster.
  4. 4. Why can a pay-per-execution service become more expensive than an always-on instance?

    Pay per use is cheap for spiky or low traffic, but past a break-even point a fixed, fully used instance costs less.

Summary

  • Compute services run from most control (VMs) to least operations (Functions); Batch is for large finite parallel jobs.
  • App Service suits standard web apps, Container Apps suits containers without cluster work, and AKS is for teams that need Kubernetes itself.
  • Ask about workload shape, triggers, packaging, OS needs and idle time before comparing prices.
  • Pay-per-use is cheapest for spiky traffic; fixed capacity can win at steady high load. Compute the break-even with real prices.
  • Keep apps stateless and configured by environment variables so you can change compute services later.

Next: Storage Accounts and Blob Storage.