Deploy and Manage Azure Compute Resources · Topic 4 of 5

Containers in Azure

AZ-104 containers: Container Registry tiers and access, Container Instances groups and restart policy, and Container Apps ingress and scaling.

  • 5 min
In a nutshell
  • ACR tiers are Basic, Standard and Premium. Geo-replication needs Premium.
  • Give ACR access with AcrPull and AcrPush roles. Keep the admin account off.
  • ACI has fixed CPU and memory per container group and no autoscale.

What it is

A container packages an application and what it needs, so that it runs the same way anywhere. Azure has three services you must tell apart. Azure Container Registry stores images. Azure Container Instances runs a container quickly with no cluster. Azure Container Apps runs containers as a serverless service with automatic scaling.

Build imageDockerfilepushAzure Container Registrystores imagespullRunContainer Instances or Container Apps

How it works

Azure Container Registry

Azure Container Registry (ACR) is a private registry for container images.

TierNotes
BasicFor learning and low volume
StandardFor most production use
PremiumAdds geo-replication and private link, with the highest throughput

Geo-replication, which keeps copies of a registry in several regions, needs the Premium tier.

az acr create --resource-group rg-app --name contosoregistry --sku Standard
az acr login --name contosoregistry
docker push contosoregistry.azurecr.io/web:v1

Access is best given through Microsoft Entra roles, such as AcrPull to run images and AcrPush to push them, assigned to a user or a managed identity. An admin account also exists. It is turned off by default and is not meant for production. ACR Tasks can build images in Azure, for example when code changes.

Azure Container Instances

Azure Container Instances (ACI) runs containers without managing servers or a cluster. Containers run in a container group, which shares a host, a network and a lifecycle, much like a pod.

  • You choose the CPU and memory for the group when you create it. ACI does not autoscale. To get more capacity you create more groups.
  • A group can have a public IP address and a DNS name label.
  • Linux and Windows containers are supported, and you can mount an Azure Files share.

The restart policy controls what happens when a container stops.

PolicyBehaviour
AlwaysRestarts the container whenever it stops. This is the default
OnFailureRestarts only if it exits with an error
NeverRuns once and is not restarted
az container create --resource-group rg-app --name web --image contosoregistry.azurecr.io/web:v1 --cpu 1 --memory 1.5 --ports 80 --dns-name-label contoso-web

Azure Container Apps

Azure Container Apps runs containers on a managed platform that is built on Kubernetes, without you managing Kubernetes. Apps live in an environment that shares networking and logging.

  • Ingress controls who can reach the app. External ingress is reachable from the internet. Internal ingress, limited to the environment, is reachable only by other apps in the environment.
  • A revision is an immutable snapshot of an app version. You can run several revisions and split traffic between them.
  • Scaling uses rules, based on HTTP traffic, CPU, memory or events such as queue messages. By default an app has a minimum of 0 and a maximum of 10 replicas.

An HTTP scale rule, or an event rule, can scale an app down to zero replicas, and you are not billed while it is at zero. CPU and memory rules cannot scale to zero.

Front end appexternal ingressBack end appinternal ingress, environment onlyScale ruleHTTP requests

Choosing a container service

NeedService
Run one container quickly, with no orchestrationAzure Container Instances
Run microservices with automatic scaling and little managementAzure Container Apps
Full control of Kubernetes for a large container platformAzure Kubernetes Service
Store and distribute the imagesAzure Container Registry

More on Container Registry

Azure Container Registry Tasks can build images in Azure, for example whenever code is committed, so that you do not need a build server. A registry is private by default. To let a service pull images, give its managed identity the AcrPull role. Use the admin account only for quick tests.

More on Container Instances

Containers in a group share a network, so they reach each other on localhost. A group can mount an Azure Files share for storage that outlives the containers. Because the CPU and memory are fixed per group, a busy workload is served by creating more groups, not by autoscale.

Container Apps revisions and traffic

Every change to the app definition can create a new revision. You can run two revisions at once and split traffic between them, for example 90 percent to the current revision and 10 percent to a new one. This is a safe way to test a release, and you can send all traffic back to the earlier revision if there is a problem.

How the exam asks about this

  • "Scale to zero when idle." Container Apps with an HTTP or event rule.
  • "A back end reachable only from other apps in the environment." Internal ingress.
  • "Pull images without a password." A managed identity with AcrPull.
  • "Replicate a registry across regions." Premium tier geo-replication.
  • "Restart only on failure." The OnFailure restart policy.

What to remember for the exam

  • ACR tiers are Basic, Standard and Premium. Geo-replication needs Premium.
  • Give ACR access with AcrPull and AcrPush roles. Keep the admin account off.
  • ACI has fixed CPU and memory per container group and no autoscale.
  • ACI restart policies are Always, OnFailure and Never, with Always as the default.
  • Container Apps scales on HTTP, CPU, memory or events, from 0 to 10 replicas by default.
  • Only HTTP and event rules can scale to zero. Internal ingress keeps an app off the internet.
Exam tip

"A back end that only other apps in the environment can call" points to internal ingress. "Scale to zero when idle" points to Container Apps with an HTTP rule.

Common mistakes

Expecting ACI to autoscale. It does not. Use Container Apps for that.

Using the ACR admin account in production. Use roles and managed identities.

Choosing a CPU rule to scale to zero. CPU and memory rules keep at least one replica.

Choosing the Basic registry for geo-replication. It needs Premium.

Check yourself

  • Which ACR tier is required for geo-replication?

    Premium.

  • What is the default restart policy for Azure Container Instances?

    Always.

  • Which Container Apps setting makes an app reachable only from other apps in the same environment?

    Internal ingress, limited to the environment.

Topic 4 of 5 in Deploy and Manage Azure Compute Resources

Test yourself on Deploy and Manage Azure Compute Resources

The full Microsoft AZ-104 question bank has 650 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Microsoft. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.