Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 1 of 28
Next❯

Containers for AI Apps: App Service, Container Apps or AKS?

Module 1: Containers ⏱ 8 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: App Service, Container Apps or AKS: one image, three create flows Compare App Service, Container Apps and AKS in the create flow.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. You have one image, chat-api:1.4.0, in Azure Container Registry. Search for container and see where it can run.
    2. Three hosts show up. Start with App Services, the one most teams already know.
    3. App Service runs one container as a web app. You pay for the plan even when nobody calls the API.
    4. Container Apps asks for an environment instead of a plan. Many apps share it, and each app can scale to zero.
    5. AKS asks about clusters, versions and node pools. Full Kubernetes control, and you look after the nodes.
    6. 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.

    😟 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
    🛠️ Solved with: Containers on Azure

    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.

    ▶ Explainer video See it in motion 7 steps · 1 min 43 sec

    An animation that turns a Python app and its Dockerfile into a layered container image, pushes it to Azure Container Registry with a version tag and a digest, runs the same image on App Service, Azure Container Apps and AKS, and shows how a moving latest tag leaves two hosts running different builds.
    Read the video script
    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
    6. 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.
    7. 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. 1 Build

      Dockerfile becomes an image (locally or with ACR Tasks).

    2. 2 Store

      Push ragapi:1.4.0 to Azure Container Registry.

    3. 3 Pull

      The host pulls with a managed identity that has AcrPull.

    4. 4 Run

      App Service, Container Apps or AKS starts the container with settings and secrets.

    One image, three hosts

    Picking a host

    App ServiceAzure Container AppsAKS
    What you manageThe app and its settingsThe app, revisions and scale rulesNode pools, upgrades, manifests, add-ons
    Best forOne web API or siteMicroservices, APIs, queue workersLarge platforms, GPU nodes, custom Kubernetes
    ScaleAutoscale rules on the plan, no scale to zeroKEDA rules (HTTP, queues, custom), can scale to zeroHorizontal Pod Autoscaler, cluster autoscaler, KEDA add-on
    ReleasesDeployment slots and swapRevisions with traffic splittingRolling updates in the Deployment
    ConfigApp settings, Key Vault referencesEnv vars, secrets, Key Vault referencesConfigMaps, Secrets, Secrets Store CSI driver
    Kubernetes APINoNoYes

    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

    Legal services

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    You are deploying a containerized Python worker that processes messages from an Azure Service Bus queue. The worker receives no messages for most of the day and must incur no compute cost while idle. You must minimize cluster management. Which service should you use?

    Question 2

    Question 2 of 5

    Your team must deploy a set of AI microservices that rely on a custom Kubernetes operator and custom resource definitions (CRDs). Which hosting option should you choose?

    Question 3

    Question 3 of 5

    A company runs a single containerized web API with steady traffic. The team wants deployment slots for staging and swapping, and the least amount of platform management. Which service should they use?

    Question 4

    Question 4 of 5 · Select 2

    You plan to run the same container image on Azure App Service, Azure Container Apps, and Azure Kubernetes Service (AKS). The image must be pulled from Azure Container Registry without storing registry passwords. Which TWO actions should you perform?

    Question 5

    Question 5 of 5

    A development team must release a new version of a containerized API to 10 percent of users before releasing it to all users. The team does not want to manage Kubernetes. Which service and feature should they use?

    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. 1.Which Azure service stores private container images?Show

      Azure Container Registry.

    2. 2.Which host scales to zero with KEDA rules?Show

      Azure Container Apps.

    3. 3.Which host uses YAML manifests and kubectl?Show

      Azure Kubernetes Service (AKS).

    4. 4.How does App Service pass settings to a container?Show

      App settings are injected as environment variables.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.