Containers for AI Apps: App Service, Container Apps or AKS?
30-second answer
A container image packs your AI app and everything it needs (Python, packages, code) into one versioned unit that you store in Azure Container Registry. You then pick a host: App Service for a single web API with the least work, Azure Container Apps for serverless microservices with revisions and KEDA scaling to zero, or Azure Kubernetes Service (AKS) when you need full Kubernetes control through manifest files.
Simulate it » No Azure account neededExam objective: 1.1.3 Deploy containers to Azure App Service, including configuring App Service to supply environment variables and secrets. 1.2.1 Deploy applications to Azure Container Apps, including environment configuration and revision management. 1.2.3 Deploy and manage applications to Azure Kubernetes Service (AKS) by using manifest files. (Skills measured as of October 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
You have one image, <code>chat-api:1.4.0</code>, in Azure Container Registry. Search for <strong>container</strong> and see where it can run.
👆 Click the glowing item in the portal to continue
Read the steps as text
- You have one image, chat-api:1.4.0, in Azure Container Registry. Search for container and see where it can run.
- Three hosts show up. Start with App Services, the one most teams already know.
- App Service runs one container as a web app. You pay for the plan even when nobody calls the API.
- Container Apps asks for an environment instead of a plan. Many apps share it, and each app can scale to zero.
- AKS asks about clusters, versions and node pools. Full Kubernetes control, and you look after the nodes.
- Rule of thumb: one steady web API → App Service. Microservices or queue workers → Container Apps. You need the Kubernetes API → AKS.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Build an image, push it to the registry
Your Python API and everything it needs are packed into a container image. You push it to Azure Container Registry (ACR) as ragapi:1.4.0. A tag names a version. A digest (sha256:…) names the exact bytes and never changes.
🤔 What happens if…
Read this tour as text
- Build an image, push it to the registry. Your Python API and everything it needs are packed into a container image. You push it to Azure Container Registry (ACR) as
ragapi:1.4.0. A tag names a version. A digest (sha256:…) names the exact bytes and never changes. - ACR Tasks build in the cloud. ACR Tasks build the image inside Azure, so you don’t need Docker on your laptop.
az acr buildis a quick task. A task can also run on every git commit or when the base image (saypython:3.12-slim) gets a security patch. - App Service runs one container. App Service pulls the image and runs it. App settings become environment variables inside the container. A setting can be a Key Vault reference, so the secret never sits in the image or in the portal in plain text.
- Container Apps environment. An Azure Container Apps environment is a secure boundary with its own virtual network and Log Analytics workspace. Several container apps share it. Ingress decides who can reach each app: external (internet) or internal (only the environment).
- Revisions and traffic splitting. Every change to the template (image, env vars, scale rules) creates a new revision, an immutable snapshot. In multiple revision mode you can send 80% of traffic to the old one and 20% to the new one, then roll forward or back.
- KEDA scales on events. Container Apps uses KEDA scale rules. A Service Bus rule adds replicas as the queue grows (for example one replica per 5 messages), up to max replicas. When the queue empties, it scales back to min replicas, which can be zero.
- AKS runs what the manifest says. On AKS you describe the app in YAML manifests: a Deployment (image, replicas, probes, resources) and a Service (a stable address).
kubectl apply -fsends them. Kubernetes keeps the real state equal to what you declared. - Troubleshoot: logs, events, connectivity. When it breaks, look in three places. Logs (
kubectl logs,az containerapp logs show) show what the app said. Events (kubectl describe,kubectl get events) show what the platform did. Connectivity checks (DNS, ports, ingress) show whether traffic can reach it.
Ship a new version of an API without a big-bang release. Create a container app, switch to multiple revisions, send 20% of users to the new one and check the logs from both sides: Cloud Shell and KQL.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Your RAG API works on your laptop and nowhere else.
😊 THE SOLUTION
Ship it as a container image and pick the right Azure host.
- “Works on my machine”✓ One image runs the same everywhere
- Too many hosting choices✓ App Service, Container Apps or AKS by need
- Traffic comes in bursts✓ Hosts that scale out and in
Start with a question
Your RAG API works on your laptop. Why does it break on the server?
The server has Python 3.10, you used 3.12. It’s missing a system library that one of your packages needs. Someone installed a different version of the OpenAI SDK last month. Every machine is a little different, and AI apps pull in a lot of packages.
A container image fixes that. You pack the code, the Python runtime and every package into one image, push it to a registry, and every host runs exactly the same thing. The question then becomes where to run it on Azure.
Explain it like I’m 10
Visual: container images in motion
Watch a Dockerfile become an image, get a tag and a digest in Azure Container Registry, and run unchanged on all three hosts.
Read the video script
- Your app and a DockerfileHere's a small Python AI back end. Next to the code sits a Dockerfile. It's a recipe: start from Python, install the packages, copy the code, then say how to start it.
- Build: the image is a stack of layersBuilding turns that recipe into an image. Each step adds a read-only layer on top of the last one. Change only your code, and only the top layers get rebuilt.
- Push it to Azure Container RegistryNow you push the image to Azure Container Registry, your private store for images, with a version tag. Here it is, ragapi, version one point four point oh.
- Every image gets a digestThe registry also gives the image a digest. That's a fingerprint of the exact bytes, and it never changes. A tag is just a label you chose, so it can be moved to another image later.
- One image, three hostsAny of the three hosts can pull that same image. App Service, Container Apps or AKS. Same Python, same packages, same code, so what you tested is what runs.
- Why :latest is riskyNow the risky bit. Say every host asks for the latest tag. Someone pushes a new build and latest moves to it. A host that pulls now gets the new code, the others still run the old one. Same tag, two builds, and rolling back is guesswork.
- Pin what you deploySo deploy a tag nobody reuses, like a version number or build ID, or the digest itself. Then every host runs the build you tested, and rolling back means picking the previous tag.
The technical explanation
You build an image from a Dockerfile. For a small FastAPI back end it looks like this:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
The image goes into Azure Container Registry (ACR) with a version tag such as ragapi:1.4.0. From there, any of the three hosts can pull it. Secrets like your model key don’t go in the image. They’re supplied at run time as environment variables or, better, fetched with a managed identity.
-
1 Build
Dockerfile becomes an image (locally or with ACR Tasks).
-
2 Store
Push ragapi:1.4.0 to Azure Container Registry.
-
3 Pull
The host pulls with a managed identity that has AcrPull.
-
4 Run
App Service, Container Apps or AKS starts the container with settings and secrets.
Picking a host
| App Service | Azure Container Apps | AKS | |
|---|---|---|---|
| What you manage | The app and its settings | The app, revisions and scale rules | Node pools, upgrades, manifests, add-ons |
| Best for | One web API or site | Microservices, APIs, queue workers | Large platforms, GPU nodes, custom Kubernetes |
| Scale | Autoscale rules on the plan, no scale to zero | KEDA rules (HTTP, queues, custom), can scale to zero | Horizontal Pod Autoscaler, cluster autoscaler, KEDA add-on |
| Releases | Deployment slots and swap | Revisions with traffic splitting | Rolling updates in the Deployment |
| Config | App settings, Key Vault references | Env vars, secrets, Key Vault references | ConfigMaps, Secrets, Secrets Store CSI driver |
| Kubernetes API | No | No | Yes |
A quick way to decide: start from App Service if it’s one web app, move to Container Apps when you need several services, event-driven workers or scale to zero, and go to AKS only when you need something Kubernetes itself gives you.
Architect level Why images and secrets stay apart
An image is shared: it’s in the registry, it’s cached on nodes, and anyone with pull rights can unpack it. A key baked into a layer stays there even if a later layer deletes the file. So images carry code, and each host injects configuration when the container starts: App Service app settings, Container Apps secrets referenced with secretref:, or Kubernetes Secrets. Pointing those at Azure Key Vault means rotating a secret doesn’t mean rebuilding an image.
Real-world business scenario
Fabrikam Legal (fictional)
- The problem
- A contract Q&A API ran on a hand-built VM. Upgrades broke packages, and an overnight batch of document summaries ran on servers sized for the morning peak.
- What they used
- One container image in Azure Container Registry. The chat API runs on App Service with Key Vault references; the summarisation worker runs on Azure Container Apps with a Service Bus scale rule and min replicas of zero.
- Why that choice
- The API needed deployment slots and steady traffic; the worker needed to sit at zero most of the day and burst when jobs arrived.
- The result
- Releases became a tag change, and the worker only runs while there's work in the queue.
When to use it and when not to
✓ Use it when…
- Your AI back end has native dependencies or pinned package versions that must match everywhere.
- You want the same artifact in dev, test and production.
- You may move between App Service, Container Apps and AKS later.
✕ Think twice when…
- A small event handler where Azure Functions code deployment is enough.
- Putting secrets inside the image to save a configuration step.
↔ Alternatives to consider
- Azure Functions for short, trigger-driven code with no container to maintain.
- Container Apps jobs for run-to-completion batch work.
Test yourself with exercises
5 original practice questions in the AI-200 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Why put an AI back end in a container at all?
Model answer
Because the same image runs the same way on my laptop, in test and in production. Python version, packages and system libraries are all inside it, so "works on my machine" stops being an excuse. It also lets me move between App Service, Container Apps and AKS without rebuilding the app.
Interviewer follows up
Where do you keep the images?
You
In a private Azure Container Registry, tagged with a version, so every host pulls exactly the build I tested.
Intermediate When would you choose Container Apps over App Service for a containerised API?
Model answer
When I have several services or background workers, want scale to zero, need event-driven scaling from a queue, or want to split traffic between revisions for a canary release. For one steady web API, App Service is simpler and has deployment slots.
Architecture & design A team wants AKS for a single Python API. How would you advise them?
Model answer
I'd ask what they need from Kubernetes directly. If the answer is nothing specific, Container Apps gives them the same container model with revisions and KEDA, minus node pools, upgrades and cluster security to own. AKS makes sense once they need custom operators, GPU node pools, service meshes or direct access to the Kubernetes API.
Scenario Your summarisation worker sits idle most of the night and gets hundreds of jobs every morning. Which host fits?
Model answer
Azure Container Apps with a KEDA Service Bus scale rule and min replicas set to zero. It costs almost nothing overnight and scales out as the queue fills.
Quick revision
Key points
- A container image bundles code, runtime and dependencies; a registry such as ACR stores and versions it.
- App Service runs one container as a web app; app settings become environment variables.
- Container Apps runs serverless containers in an environment, with revisions, traffic splitting and KEDA scaling (including to zero).
- AKS gives full Kubernetes; you describe workloads in YAML manifests and apply them with kubectl.
- All three can pull from ACR with a managed identity that has the AcrPull role.
Important terminology
- Container image
- A read-only package of an app and its dependencies, built from a Dockerfile and run as a container.
- Azure Container Registry (ACR)
- A private, managed registry in Azure that stores container images and other OCI artifacts.
- App Service (custom container)
- Platform as a service that runs one container image as a web app with TLS, slots and autoscale.
- Azure Container Apps
- Serverless container hosting built on Kubernetes and KEDA, without a cluster to manage.
- Azure Kubernetes Service (AKS)
- Managed Kubernetes where Azure runs the control plane and you deploy workloads with YAML manifests.
Common mistakes
- Picking AKS for a single API when nobody needs direct Kubernetes access.
- Expecting App Service to scale to zero or scale on queue length the way Container Apps does.
Exam tips
- "Scale to zero on queue messages" or "split traffic between versions" = Azure Container Apps.
- "Full control of the Kubernetes API" or "apply Deployment and Service manifests" = AKS.
- "Run one containerised web app with deployment slots and minimal management" = App Service.
Five quick revision questions
-
1.Which Azure service stores private container images?Show
Azure Container Registry.
-
2.Which host scales to zero with KEDA rules?Show
Azure Container Apps.
-
3.Which host uses YAML manifests and kubectl?Show
Azure Kubernetes Service (AKS).
-
4.How does App Service pass settings to a container?Show
App settings are injected as environment variables.
-
5.Which role lets a managed identity pull from ACR?Show
AcrPull.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Azure Container Registry: Store, Tag and Manage Images
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.