Containers on Azure without a cluster: ACR, Container Instances, Container Apps
Azure II ran containers on AKS: a Kubernetes cluster you upgrade, scale and pay for around the clock. Plenty of workloads do not need one. A nightly report job, a webhook receiver, an internal API with three users - for those Azure has two serverless options, Azure Container Instances (ACI) and Azure Container Apps, and both pull their images from the same place AKS does, an Azure Container Registry (ACR). This lesson builds an image in ACR without Docker on your machine, runs it on ACI, then on Container Apps with revisions, a traffic split and scale rules.
Need to know: ACR comes in Basic, Standard and Premium (Premium adds geo-replication, private endpoints, zone redundancy); pulls are authorised with Microsoft Entra (the AcrPull role) - the admin user is a shared password for emergencies. az acr build builds in Azure (ACR Tasks), az acr import copies an image in. ACI runs a container group (one or more containers on one host, sized in vCPU and GB, with a restart policy Always / OnFailure / Never) - no scaling, no load balancing. Container Apps runs apps in an environment, with ingress, immutable revisions (single or multiple active), traffic splitting, and scale rules (HTTP concurrency, TCP, CPU/memory, queues - KEDA under the hood) between min and max replicas, down to zero.
The registry
$ cd ~/oncall-lab/labs/4b-azure/az5/containers
$ cat app/Dockerfile
FROM nginx:1.27-alpine
COPY index.html /usr/share/nginx/html/
$ az acr create -g rg-az5-apps -n acrreports5 --sku Basic --query "{server:loginServer, sku:sku.name, admin:adminUserEnabled}" -o json
{
"admin": false,
"server": "acrreports5.azurecr.io",
"sku": "Basic"
}
The registry name is global (acrreports5.azurecr.io), 5-50 alphanumerics, no dashes. The SKUs differ in included storage, throughput and a few features:
| Basic | Standard | Premium | |
|---|---|---|---|
| use | dev, small teams | most production | many regions, private networks |
| geo-replication | - | - | yes |
| private endpoints, firewall rules | - | - | yes |
| zone redundancy | - | - | yes |
| content trust, customer-managed keys | - | - | yes |
You can change SKU later (az acr update --sku Premium) without losing images.
Build without Docker. az acr build uploads the build context (here the app folder) and runs the docker build in Azure (an ACR Task), then pushes the result:
$ az acr build -r acrreports5 -t reports:v1 app 2>/dev/null | tail -4
tag: 1.27-alpine
git: {}
Run ID: c1 was successful after 25s
$ az acr repository list -n acrreports5 -o tsv
reports
$ az acr repository show-tags -n acrreports5 --repository reports -o tsv
v1
az acr import --source docker.io/library/nginx:1.27 --image nginx:1.27 copies an image from another registry without pulling it through your machine - the way to stop depending on Docker Hub's rate limits in production. ACR Tasks can also rebuild on a git push or when a base image is updated.
Who may pull. Three ways, best first:
- Microsoft Entra identities with a role:
AcrPull(pull),AcrPush(push and pull), on the registry. Your ownaz acr loginuses your account; AKS, ACI, Container Apps and App Service use a managed identity with AcrPull. - Repository-scoped tokens for a CI system outside Azure.
- The admin user (
az acr update --admin-enabled true): one shared username and two passwords with push and pull on everything. Off by default; policy usually keeps it off.
Azure Container Instances: one container group, now
$ az container create -g rg-az5-apps -n aci-reports --image acrreports5.azurecr.io/reports:v1 --cpu 1 --memory 1.5 --ports 80 --ip-address Public --dns-name-label reports-az5-01 --os-type Linux
ERROR: (InaccessibleImage) The image 'acrreports5.azurecr.io/reports:v1' in container group 'aci-reports' is not accessible. Please check the image and registry credential.
Code: InaccessibleImage
Message: The image 'acrreports5.azurecr.io/reports:v1' in container group 'aci-reports' is not accessible. Please check the image and registry credential.
A private registry and no credentials: InaccessibleImage. The fix is an identity that may pull
- a user-assigned managed identity with AcrPull on the registry, named twice: as the group's
identity and as the one to pull with:
$ az identity create -g rg-az5-apps -n id-reports -o none
$ az role assignment create --assignee $(az identity show -g rg-az5-apps -n id-reports --query principalId -o tsv) --role AcrPull --scope $(az acr show -n acrreports5 --query id -o tsv) -o none
$ ID=$(az identity show -g rg-az5-apps -n id-reports --query id -o tsv)
$ az container create -g rg-az5-apps -n aci-reports --image acrreports5.azurecr.io/reports:v1 --cpu 1 --memory 1.5 --ports 80 --ip-address Public --dns-name-label reports-az5-01 --os-type Linux --assign-identity $ID --acr-identity $ID --query "{state:instanceView.state, fqdn:ipAddress.fqdn, restart:restartPolicy}" -o json
{
"fqdn": "reports-az5-01.westeurope.azurecontainer.io",
"restart": "Always",
"state": "Running"
}
$ curl -s http://reports-az5-01.westeurope.azurecontainer.io/
<h1>reports v1</h1>
$ az container logs -g rg-az5-apps -n aci-reports
/docker-entrypoint.sh: Configuration complete; ready for start up
198.51.100.24 - - [Tue, 22 Sep 2026 20:00:30 GMT] "GET / HTTP/1.1" 200 - "-" "curl/8.14.1"
What to know about ACI:
- Sizing is per container (
--cpu,--memoryin GB) and the group gets the sum; there is a per-group maximum per region (here 4 vCPU and 16 GB for Linux), and you pay per second for what you requested, from start to stop. - Restart policy:
Always(the default - a web server),OnFailure(a job that should retry on a non-zero exit),Never(run once, keep the exit code for you to read). A batch job withAlwaysis restarted forever after it succeeds. - No scaling, no load balancer, no rolling update. One group is one set of containers on one host; for more, you create more groups. Changing the image means recreating the group (same command, same name).
- A public IP + DNS label, or
--vnet/--subnetfor a private one (the subnet is delegated toMicrosoft.ContainerInstance/containerGroups).
Container Apps: an app platform on top of Kubernetes you never see
A Container Apps environment is the boundary: apps in one environment share a virtual network, a Log Analytics workspace for their logs and a default domain. Apps are created into it:
$ az containerapp env create -g rg-az5-apps -n cae-reports -l westeurope -o none
Container Apps environment created. To deploy a container app, use: az containerapp create --help
$ az containerapp create -g rg-az5-apps -n reports-api --environment cae-reports --image acrreports5.azurecr.io/reports:v1 --registry-server acrreports5.azurecr.io --registry-identity $ID --target-port 80 --ingress external --cpu 0.5 --memory 1.0Gi --min-replicas 1 --max-replicas 5 --scale-rule-name http-load --scale-rule-type http --scale-rule-http-concurrency 30 --query properties.configuration.ingress.fqdn -o tsv
Container app created. Access your app at https://reports-api.calmcloud-05e8ebc0.westeurope.azurecontainerapps.io/
reports-api.calmcloud-05e8ebc0.westeurope.azurecontainerapps.io
$ curl -s https://$(az containerapp show -g rg-az5-apps -n reports-api --query properties.configuration.ingress.fqdn -o tsv)/
<h1>reports v1</h1>
Ingress external gives the app a public HTTPS endpoint with a managed certificate; internal makes it reachable only inside the environment; no ingress at all suits background workers. --target-port is the port the container listens on.
Sizing comes in fixed CPU/memory pairs on the Consumption plan (0.25 vCPU / 0.5 GiB, 0.5 / 1.0, 0.75 / 1.5 ...). Anything else is refused:
$ az containerapp update -g rg-az5-apps -n reports-api --cpu 0.75 --memory 1.0Gi
ERROR: (ContainerAppInvalidResourceTotal) The total requested CPU and memory resources for this application (CPU: 0.75, memory: 1.0Gi) is invalid. Total CPU and memory for all containers defined in a Container App must add up to one of the following CPU - Memory combinations: [cpu: 0.25, memory: 0.5Gi]; [cpu: 0.5, memory: 1.0Gi]; [cpu: 0.75, memory: 1.5Gi]; [cpu: 1.0, memory: 2.0Gi]; [cpu: 1.25, memory: 2.5Gi]; [cpu: 1.5, memory: 3.0Gi]; [cpu: 1.75, memory: 3.5Gi]; [cpu: 2.0, memory: 4.0Gi]
Code: ContainerAppInvalidResourceTotal
Message: The total requested CPU and memory resources for this application (CPU: 0.75, memory: 1.0Gi) is invalid. Total CPU and memory for all containers defined in a Container App must add up to one of the following CPU - Memory combinations: [cpu: 0.25, memory: 0.5Gi]; [cpu: 0.5, memory: 1.0Gi]; [cpu: 0.75, memory: 1.5Gi]; [cpu: 1.0, memory: 2.0Gi]; [cpu: 1.25, memory: 2.5Gi]; [cpu: 1.5, memory: 3.0Gi]; [cpu: 1.75, memory: 3.5Gi]; [cpu: 2.0, memory: 4.0Gi]
Scaling is replicas between --min-replicas and --max-replicas, driven by scale rules:
| rule type | scales on | example |
|---|---|---|
http | concurrent HTTP requests per replica | 30 requests in flight -> one more replica |
tcp | concurrent TCP connections | a gRPC or database proxy |
| custom (KEDA) | CPU, memory, queue length, Kafka lag, cron... | 1 replica per 100 messages in a Service Bus queue |
With --min-replicas 0 an idle app costs nothing - and the first request after a quiet period waits for a replica to start (a cold start, seconds). Keep min 1 for anything a user waits on. With no scale rule, a Consumption app scales on HTTP with a default concurrency of 10.
$ az containerapp show -g rg-az5-apps -n reports-api --query "properties.template.scale" -o json
{
"maxReplicas": 5,
"minReplicas": 1,
"rules": [
{
"http": {
"metadata": {
"concurrentRequests": "30"
}
},
"name": "http-load"
}
]
}
Revisions and traffic splitting
Every change to the template (image, environment variables, CPU, scale) creates a new immutable revision named <app>--<suffix>. In single revision mode (the default) the new one takes all traffic and the old one is deactivated. In multiple mode several revisions run at once and you choose the split - a canary without any extra tooling:
$ az containerapp revision set-mode -g rg-az5-apps -n reports-api --mode multiple
"Multiple"
$ sed -i 's/v1/v2/' app/index.html && az acr build -r acrreports5 -t reports:v2 app >/dev/null 2>&1
$ az containerapp update -g rg-az5-apps -n reports-api --image acrreports5.azurecr.io/reports:v2 --revision-suffix v2 -o none
$ az containerapp revision list -g rg-az5-apps -n reports-api --query "[].{revision:name, active:properties.active, traffic:properties.trafficWeight}" -o table
Revision Active Traffic
-------------------- ------ -------
reports-api--a1928d9 True 0
reports-api--v2 True 100
$ OLD=$(az containerapp revision list -g rg-az5-apps -n reports-api --query "[0].name" -o tsv)
$ az containerapp ingress traffic set -g rg-az5-apps -n reports-api --revision-weight $OLD=80 reports-api--v2=20 -o table
RevisionName Weight
-------------------- ------
reports-api--a1928d9 80
reports-api--v2 20
$ for i in $(seq 10); do curl -s https://$(az containerapp show -g rg-az5-apps -n reports-api --query properties.configuration.ingress.fqdn -o tsv)/; done | sort | uniq -c
8 <h1>reports v1</h1>
2 <h1>reports v2</h1>
Look at the revision list first: the moment v2 was ready it had 100%. The app's traffic rule was still the default, "latest revision: 100" - so in multiple mode, set the weights by revision name before you deploy the canary (or deploy it with --revision-weight pinned), or the "canary" is a full rollout. After the split, two in ten requests see v2. When it looks healthy, move the weights to 100 for v2 and deactivate the old revision; if not, set the old one back to 100 - a rollback in seconds, no redeploy. Weights must add up to 100, and only active revisions can receive traffic.
Choosing
| need | use |
|---|---|
| a container now, for minutes or hours; a batch job; a sidecar-free tool | ACI |
| an HTTP API or worker that scales with load (to zero), canaries, no cluster to run | Container Apps |
| full Kubernetes: custom controllers, daemonsets, node control, a platform for many teams | AKS |
| a plain web app or API from code (no container) | App Service (next lesson) |
On the exam (AZ-104 3.3.1-3.3.4): "pull from ACR without storing a password" = a managed identity with AcrPull; "geo-replication / private endpoint for the registry" = Premium; "a job that should not restart after it succeeds" = restart policy OnFailure or Never; "scale to zero" and "split traffic between versions" = Container Apps; "scale the number of ACI instances automatically" = not ACI.
In an interview: "When would you pick Container Apps over AKS?" - "When the team wants to run containers, not operate Kubernetes: HTTP APIs and workers with scale-to-zero, revisions and traffic splits built in, and no node pools to upgrade. AKS when we need the Kubernetes API itself - operators, daemonsets, network policies, a shared platform for many teams."