0
0
Azurecloud~5 mins

AKS vs App Service vs Functions decision in Azure - CLI Comparison

Choose your learning style9 modes available
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.