Bird
Raised Fist0
Azurecloud~5 mins

AKS vs App Service vs Functions 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
Choosing the right way to run your app on Azure can be confusing. AKS, App Service, and Functions each solve different problems about how your app runs and scales.
Use AKS when you want full control over containers and need to run many apps together with complex networking.
Use App Service when you want to quickly deploy web apps without managing servers or infrastructure.
Use Functions when you want to run small pieces of code that respond to events and scale automatically.
Commands
This command creates an AKS cluster with 2 nodes and monitoring enabled. It sets up the environment to run containerized apps with Kubernetes.
Terminal
az aks create --resource-group example-rg --name example-aks --node-count 2 --enable-addons monitoring --generate-ssh-keys
Expected OutputExpected
Waiting for AAD role to propagate Succeeded { "agentPoolProfiles": [ { "count": 2, "maxPods": 110, "name": "nodepool1", "osType": "Linux", "vmSize": "Standard_DS2_v2" } ], "fqdn": "example-aks-12345.hcp.eastus.azmk8s.io", "kubernetesVersion": "1.26.3", "location": "eastus", "name": "example-aks", "resourceGroup": "example-rg", "type": "Microsoft.ContainerService/ManagedClusters" }
--node-count - Sets how many nodes the cluster will have
--enable-addons - Adds extra features like monitoring
This command creates an App Service web app using a specified plan and runtime. It lets you deploy web apps without managing servers.
Terminal
az webapp create --resource-group example-rg --plan example-plan --name example-app --runtime "DOTNET|7.0"
Expected OutputExpected
{ "id": "/subscriptions/xxxx/resourceGroups/example-rg/providers/Microsoft.Web/sites/example-app", "name": "example-app", "state": "Running", "type": "Microsoft.Web/sites" }
--plan - Specifies the App Service plan that defines the compute resources
--runtime - Sets the language and version your app uses
This command creates a serverless Function App that runs Python code. It uses a consumption plan that scales automatically based on demand.
Terminal
az functionapp create --resource-group example-rg --consumption-plan-location eastus --runtime python --functions-version 4 --name example-func --storage-account examplestorage
Expected OutputExpected
{ "id": "/subscriptions/xxxx/resourceGroups/example-rg/providers/Microsoft.Web/sites/example-func", "name": "example-func", "state": "Running", "type": "Microsoft.Web/sites" }
--consumption-plan-location - Sets the region and plan type for serverless scaling
--runtime - Specifies the language runtime for the function
This command downloads the credentials to connect to the AKS cluster so you can manage it with kubectl.
Terminal
az aks get-credentials --resource-group example-rg --name example-aks
Expected OutputExpected
Merged "example-aks" as current context in /home/user/.kube/config
This command lists the nodes in your AKS cluster to verify it is running and ready.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION aks-nodepool1-12345678-vmss000000 Ready agent 5m v1.26.3
Key Concept

If you remember nothing else from this pattern, remember: AKS is for container control, App Service is for easy web apps, and Functions are for event-driven code.

Common Mistakes
Trying to use Functions for long-running apps
Functions are designed for short, event-driven tasks and may time out or cost more if used for long processes
Use App Service or AKS for apps that run continuously or need complex logic
Deploying complex multi-container apps directly to App Service without containers
App Service supports containers but is limited for complex orchestration and scaling compared to AKS
Use AKS for multi-container or microservices apps needing advanced networking
Not setting up monitoring when creating AKS
Without monitoring, you can't easily see cluster health or logs, making troubleshooting hard
Always enable monitoring addon during AKS creation
Summary
Create AKS for full container orchestration with control over nodes and scaling.
Use App Service to quickly deploy and manage web apps without infrastructure management.
Choose Functions for small, event-triggered code that scales automatically.

Practice

(1/5)
1. Which Azure service is best suited for hosting a simple web application with minimal infrastructure management?
easy
A. Azure App Service
B. Azure Kubernetes Service (AKS)
C. Azure Functions
D. Azure Virtual Machines

Solution

  1. Step 1: Understand service purpose

    Azure App Service is designed for easy hosting of web apps without managing infrastructure.
  2. Step 2: Compare with other options

    AKS is for container orchestration, Functions are for event-driven code, and VMs require full management.
  3. Final Answer:

    Azure App Service -> Option A
  4. Quick Check:

    Simple web app hosting = Azure App Service [OK]
Hint: Simple web app? Choose App Service for easy hosting [OK]
Common Mistakes:
  • Choosing AKS for simple apps needing no container orchestration
  • Using Functions for always-on web apps
  • Selecting VMs when managed service suffices
2. Which Azure service is primarily designed for running event-driven code without managing servers?
easy
A. Azure Kubernetes Service (AKS)
B. Azure App Service
C. Azure Functions
D. Azure SQL Database

Solution

  1. Step 1: Identify event-driven service

    Azure Functions is a serverless compute service designed for event-driven code execution.
  2. Step 2: Exclude other services

    AKS manages containers, App Service hosts web apps, SQL Database stores data.
  3. Final Answer:

    Azure Functions -> Option C
  4. Quick Check:

    Event-driven code = Azure Functions [OK]
Hint: Event-driven code? Use Azure Functions [OK]
Common Mistakes:
  • Confusing AKS with serverless functions
  • Using App Service for event triggers
  • Selecting SQL Database as compute
3. You want to deploy a microservices app using containers with full control over scaling and networking. Which Azure service fits best?
medium
A. Azure Functions
B. Azure Kubernetes Service (AKS)
C. Azure App Service
D. Azure Logic Apps

Solution

  1. Step 1: Analyze requirements

    Microservices with containers needing control over scaling and networking require container orchestration.
  2. Step 2: Match service capabilities

    AKS provides Kubernetes orchestration with control; App Service and Functions are more managed and less flexible.
  3. Final Answer:

    Azure Kubernetes Service (AKS) -> Option B
  4. Quick Check:

    Container orchestration with control = AKS [OK]
Hint: Need container control? Pick AKS [OK]
Common Mistakes:
  • Choosing App Service for container orchestration
  • Using Functions for microservices with containers
  • Confusing Logic Apps with container hosting
4. A developer deployed a containerized app to Azure App Service but notices scaling and networking options are limited. What is the likely cause?
medium
A. Azure Functions must be enabled for scaling
B. Azure App Service requires manual VM scaling
C. The app needs to be deployed on Azure SQL Database
D. Azure App Service does not support container orchestration like AKS

Solution

  1. Step 1: Understand service limits

    Azure App Service supports containers but lacks full orchestration and advanced networking control.
  2. Step 2: Identify correct cause

    AKS provides container orchestration with scaling and networking control; App Service is more managed and limited.
  3. Final Answer:

    Azure App Service does not support container orchestration like AKS -> Option D
  4. Quick Check:

    Limited scaling in App Service = no full orchestration [OK]
Hint: Limited container control? App Service lacks orchestration [OK]
Common Mistakes:
  • Thinking Functions enable App Service scaling
  • Confusing SQL Database as app host
  • Assuming manual VM scaling is needed in App Service
5. A company wants to build a highly scalable API backend that triggers code on HTTP requests and other events, with minimal infrastructure management. Which Azure service should they choose and why?
hard
A. Azure Functions for event-driven, serverless execution with automatic scaling
B. Azure App Service for easy web app hosting with built-in scaling
C. Azure Virtual Machines for custom environment and manual scaling
D. Azure Kubernetes Service (AKS) for full control and container orchestration

Solution

  1. Step 1: Analyze requirements

    The company needs highly scalable API backend triggered by HTTP and other events with minimal management.
  2. Step 2: Match service features

    Azure Functions provide serverless, event-driven execution with automatic scaling and minimal infrastructure management.
  3. Step 3: Exclude other options

    AKS offers control but requires management; App Service is good but less event-driven; VMs need manual management.
  4. Final Answer:

    Azure Functions for event-driven, serverless execution with automatic scaling -> Option A
  5. Quick Check:

    Event-driven + minimal management = Azure Functions [OK]
Hint: Event-driven API with auto scale? Use Functions [OK]
Common Mistakes:
  • Choosing AKS despite high management overhead
  • Selecting App Service ignoring event triggers
  • Using VMs which need manual scaling