Bird
Raised Fist0
Azurecloud~5 mins

Serverless vs PaaS vs IaaS decision in Azure - CLI Comparison

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Azure offers three main service models — IaaS, PaaS, and Serverless — each giving you a different level of control and responsibility. Choosing the wrong model means either managing too much infrastructure or paying for idle capacity you don't need.
When you need full OS control and custom networking — use IaaS (Azure VMs).
When you want to deploy an app without managing servers or OS updates — use PaaS (Azure App Service).
When you have event-driven workloads that run occasionally and scale to zero — use Serverless (Azure Functions).
When you migrate a legacy app that requires specific OS configuration — use IaaS.
When you build APIs or microservices that need automatic scaling without managing infrastructure — use PaaS or Serverless.
Commands
Creates a Serverless Azure Function App with a consumption plan — you pay only when the function runs. Scale to zero when idle.
Terminal
az functionapp create --resource-group myResourceGroup --consumption-plan-location eastus --runtime python --runtime-version 3.9 --functions-version 4 --name myFunctionApp --storage-account mystorage123
Expected OutputExpected
{ "availabilityState": "Normal", "defaultHostName": "myfunctionapp.azurewebsites.net", "kind": "functionapp", "name": "myFunctionApp", "resourceGroup": "myResourceGroup", "state": "Running", "type": "Microsoft.Web/sites" }
--consumption-plan-location - Uses serverless consumption pricing — pay per execution
--runtime python - Sets the function runtime language
Creates a PaaS web app on Azure App Service. You manage the app code, Azure manages the OS, runtime, and scaling.
Terminal
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name myWebApp --runtime "PYTHON:3.9"
Expected OutputExpected
{ "defaultHostName": "mywebapp.azurewebsites.net", "kind": "app", "name": "myWebApp", "resourceGroup": "myResourceGroup", "state": "Running", "type": "Microsoft.Web/sites" }
--plan - Specifies the App Service plan (defines compute tier)
--runtime - Sets the language runtime for the web app
Creates an IaaS virtual machine. You control the OS, install software, and manage patches — full control, full responsibility.
Terminal
az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
Expected OutputExpected
{ "fqdns": "", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM", "location": "eastus", "name": "myVM", "powerState": "VM running", "resourceGroup": "myResourceGroup" }
--image UbuntuLTS - Specifies the OS image for the VM
--generate-ssh-keys - Creates SSH keys for secure access
Key Concept

If you remember nothing else from this pattern, remember: IaaS = you manage OS and above, PaaS = you manage code only, Serverless = you manage functions only and pay per execution.

Common Mistakes
Choosing IaaS for a simple web app because it feels more familiar
You end up managing OS updates, security patches, and scaling manually when PaaS handles all of that automatically.
Use Azure App Service (PaaS) for web apps — deploy code and let Azure manage the infrastructure.
Using Serverless for long-running or stateful workloads
Azure Functions have execution time limits and are stateless — long jobs will time out.
Use PaaS (App Service) or IaaS (VM) for workloads that run longer than a few minutes or need persistent state.
Forgetting that IaaS VMs cost money even when idle
A stopped VM still incurs storage costs. A running VM costs per hour regardless of load.
Use Serverless or PaaS for variable workloads — they scale to zero or scale automatically based on demand.
Summary
Use Azure Functions (Serverless) for event-driven, short-lived workloads — pay only per execution.
Use Azure App Service (PaaS) for web apps and APIs — manage code only, Azure handles infrastructure.
Use Azure VMs (IaaS) when you need full OS control, custom networking, or legacy app support.

Practice

(1/5)
1. Which Azure service model lets you run your code without worrying about managing servers and charges you only when your code runs?
easy
A. Serverless
B. PaaS
C. IaaS
D. On-premises servers

Solution

  1. Step 1: Understand Serverless model

    Serverless runs your code without managing servers and charges based on usage.
  2. Step 2: Compare with PaaS and IaaS

    PaaS provides a platform but you still deploy apps; IaaS requires managing virtual machines.
  3. Final Answer:

    Serverless -> Option A
  4. Quick Check:

    Serverless = code runs without server management [OK]
Hint: Serverless = no server management, pay per execution [OK]
Common Mistakes:
  • Confusing PaaS with Serverless
  • Thinking IaaS is serverless
  • Assuming on-premises is cloud
2. Which Azure service model requires you to manage virtual machines and network settings yourself?
easy
A. Serverless
B. SaaS
C. PaaS
D. IaaS

Solution

  1. Step 1: Identify IaaS responsibilities

    IaaS gives full control over virtual machines and network settings, so you manage them.
  2. Step 2: Contrast with other models

    Serverless and PaaS abstract server management; SaaS is software delivered fully managed.
  3. Final Answer:

    IaaS -> Option D
  4. Quick Check:

    IaaS = manage VMs and network [OK]
Hint: IaaS means managing your own virtual machines [OK]
Common Mistakes:
  • Mixing PaaS with IaaS management level
  • Thinking Serverless requires VM management
  • Confusing SaaS with IaaS
3. You want to deploy a web app quickly without managing servers but need some control over the environment. Which Azure model fits best?
medium
A. Serverless
B. PaaS
C. IaaS
D. On-premises

Solution

  1. Step 1: Analyze deployment needs

    Quick deployment without server management suggests Serverless or PaaS.
  2. Step 2: Consider control over environment

    Serverless offers less control; PaaS provides a ready platform with some environment control.
  3. Final Answer:

    PaaS -> Option B
  4. Quick Check:

    PaaS = quick deploy + some control [OK]
Hint: PaaS balances ease and control for app deployment [OK]
Common Mistakes:
  • Choosing Serverless when environment control is needed
  • Picking IaaS for quick deployment
  • Confusing on-premises with cloud models
4. A developer deployed an app on Azure IaaS but forgot to configure the network security group. What is the likely issue?
medium
A. App is exposed to the internet without protection
B. App will not run because code is missing
C. Azure automatically secures the app by default
D. App will run serverless without VMs

Solution

  1. Step 1: Understand IaaS network responsibility

    In IaaS, you must configure network security groups to protect VMs and apps.
  2. Step 2: Consequence of missing security group

    Without it, the app is exposed to the internet without firewall protection.
  3. Final Answer:

    App is exposed to the internet without protection -> Option A
  4. Quick Check:

    IaaS needs manual network security setup [OK]
Hint: IaaS needs manual network security setup [OK]
Common Mistakes:
  • Assuming Azure auto-secures IaaS apps
  • Thinking app won't run without code
  • Confusing serverless with IaaS
5. Your company needs to run a batch job that runs only a few minutes every day, with minimal management and cost. Which Azure model should you choose?
hard
A. IaaS with dedicated VMs running 24/7
B. PaaS with always-on app service
C. Serverless functions triggered by schedule
D. On-premises servers scheduled manually

Solution

  1. Step 1: Analyze job characteristics

    The batch job runs briefly daily, so paying for always-on resources wastes money.
  2. Step 2: Match model to cost and management needs

    Serverless functions run only when triggered, minimizing cost and management.
  3. Step 3: Eliminate other options

    IaaS and PaaS keep resources running continuously, increasing cost; on-premises adds manual overhead.
  4. Final Answer:

    Serverless functions triggered by schedule -> Option C
  5. Quick Check:

    Short, infrequent jobs = Serverless [OK]
Hint: Use serverless for short, infrequent tasks to save cost [OK]
Common Mistakes:
  • Choosing always-on VMs for short jobs
  • Picking PaaS without considering cost
  • Ignoring serverless scheduling options