Lesson 1 of 3 Deploying Applications to Azure Container Apps

Understanding Azure Container Apps

This lesson explains Container Apps environments, apps and jobs, ingress and probes, and how apps receive configuration, secrets and images.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe environments, container apps and jobs.
  • Distinguish external from internal ingress.
  • Explain how secrets and Key Vault references reach containers.
  • Describe how apps pull from ACR with a managed identity.

What Container Apps provides

Azure Container Apps is a managed platform for running containers. Internally it uses Kubernetes, KEDA for event-driven scaling, Envoy for ingress and optionally Dapr for service-to-service features, but none of these has to be operated: there are no nodes to patch, no control plane to upgrade and no kubectl access. A developer describes the app's containers, scaling and ingress, and the platform runs it.

The platform suits the back ends of AI solutions well. An API that calls a model endpoint can scale with HTTP traffic; a worker that embeds documents can scale on the length of a Service Bus queue and shrink to zero when there is nothing to do; a nightly batch job can run as a Container Apps job. All of them can share one environment, one virtual network and one log destination.

Environments, apps and jobs

Three resource types make up a deployment, and each has its own role.

  • An environment is the secure boundary around a group of apps and jobs. Apps in one environment share a virtual network, can call each other by name, and write logs to the same Log Analytics workspace. Separate environments are used when apps must never share compute or network, such as test and production.
  • A container app runs one or more containers per replica, scales its replicas automatically, and can expose an HTTP or TCP endpoint. It is the right type for long-running services and workers.
  • A job runs containers that start, do a finite piece of work and exit. Jobs are triggered manually, on a schedule or by events, which suits batch embedding runs or periodic clean-up.

The default environment type is a workload profiles environment. It always offers the serverless Consumption profile, billed per second of vCPU and memory with scale to zero, and can add Dedicated profiles with reserved machines of a chosen size, including GPU profiles, for predictable cost or larger replicas. The older Consumption-only environment type is a legacy option.

Sort into groups

App or job?

Exam skills 1.2.1

Decide whether each workload should run as a container app or a Container Apps job.

Log in to try this activity Interactive activities are free with an account.

Ingress, ports and probes

Ingress controls how traffic reaches an app. With external ingress the app gets a public HTTPS endpoint; with internal ingress it is reachable only from inside the environment and its virtual network, which suits back-end services called by other apps. The target port must be the port on which the container listens; a mismatch is a frequent cause of failed revisions. HTTP ingress terminates TLS and supports HTTP/1.1 and HTTP/2, and TCP ingress supports other protocols.

Apps can define health probes. A startup probe gives a slow-starting container time before other probes run, a liveness probe restarts a container that stops responding, and a readiness probe keeps a replica out of the load balancer until it is ready, for example until a model has loaded. If no probes are defined, the platform applies default TCP probes on the target port.

The following diagram shows a public front end and an internal model gateway in one Container Apps environment, their ingress and how the gateway obtains its key.

A public front end and an internal model gateway in one Container Apps environment. Users reach only the front end, which calls the gateway by name over the environment's network. The gateway has internal ingress, so there is no route to it from the internet. Its API key is an app secret that references Key Vault through the gateway's managed identity and reaches the container through secretref.
After each monthly rotation, restarting the active revision reads the new value.
Match the pairs

Ingress and probes

Exam skills 1.2.1

Match each requirement with the Container Apps setting that meets it.

Log in to try this activity Interactive activities are free with an account.

Configuration, secrets and registries

Each container receives environment variables as plain values or as references to secrets. Secrets are defined at the app level and referenced by name with secretref:, so the value never appears in the container definition. A secret can hold a literal value or be a Key Vault reference that the app resolves with a managed identity.

The app pulls images from registries listed in its configuration. For ACR, the app can authenticate with its managed identity instead of a password. The following commands create an environment and an app that pulls with its system-assigned identity, receives a Key Vault secret and exposes port 8000 externally.

az containerapp env create --resource-group RG --name ENV --location LOCATION
az containerapp create --resource-group RG --name orders-api --environment ENV \
  --image REGISTRY.azurecr.io/orders-api:7f3c2ab \
  --registry-server REGISTRY.azurecr.io --registry-identity system \
  --system-assigned --ingress external --target-port 8000 \
  --secrets "db-password=keyvaultref:https://VAULT.vault.azure.net/secrets/db-password,identityref:system" \
  --env-vars DB_HOST=pg-orders.postgres.database.azure.com DB_PASSWORD=secretref:db-password

Two details matter in practice. The identity must hold AcrPull on the registry and Key Vault Secrets User on the vault before the app can start, so some teams use a user-assigned identity whose roles are granted in advance. And because secrets belong to the app's configuration rather than to a revision, changing a secret's value does not create a new revision; existing replicas keep the old value until the revision is restarted or a new revision is created.

Related capabilities

Container Apps can also host Azure Functions in containers and run Dapr sidecars for service invocation, state and publish-subscribe. Neither is required for the exam skills, but both are reasons to place related apps in the same environment.

Spot the bug

A container app that cannot start

Exam skills 1.2.1 · 4.1.1

Find the lines that stop this container app from pulling its image and reading its secret safely.

Log in to try this activity Interactive activities are free with an account.
Worked example

An internal model gateway

A company runs a public web front end and a model gateway service in Container Apps. The gateway calls an external model API with a key that must be rotated monthly, and it must never be reachable from the internet. The front end calls the gateway by name.

Both apps belong in the same environment, so that the front end can reach the gateway over the environment's network. The gateway uses internal ingress with the correct target port. Its API key is an app secret that references Key Vault through the gateway's managed identity, exposed to the container as an environment variable with secretref:. After each monthly rotation, the team restarts the active revision so that the new value is read.

External ingress with IP restrictions would still publish the gateway on the internet. Placing the key as a plain environment variable would put the secret in the app definition. A separate environment for the gateway would stop the front end from reaching it by its internal name.

Check yourself

Why does changing a secret's value in a container app not change the value that running containers see?

Show answer

Secrets belong to the app's configuration, not to a revision, so the change creates no new revision. Containers read secret values at start-up, so the revision must be restarted or replaced.

Exam Tips

Remember for the exam

  • An environment shares a virtual network and log destination among its apps and jobs.
  • Internal ingress keeps an app reachable only inside the environment.
  • Target port must match the container's listening port.
  • Secrets can be Key Vault references; a changed secret needs a revision restart.