Last updated: May 2026
Azure ContainersBeginnerAZ-104⏱ 10 min read

Azure Container Instances

Azure Container Instances (ACI) is the fastest and simplest way to run a container in Azure. No VMs to manage, no Kubernetes cluster to configure — just provide an image and ACI runs it within seconds. It's serverless containers: you pay per second of CPU and memory used, and it scales to zero when stopped.

What you'll learn What ACI is and when to use it · Container groups — multi-container pods · Restart policies (Always, Never, OnFailure) · Networking — public IP, DNS, VNet · Persistent storage with Azure Files · Creating ACI via CLI · ACI vs AKS vs Container Apps

What is ACI?

ACI runs containers directly on Azure infrastructure — no cluster, no node management, no orchestration setup. You specify an image, CPU, memory, and ACI handles everything else. Containers are billed per-second for actual CPU and memory used.

FeatureDetail
Startup timeSeconds
OS supportLinux and Windows containers
Max CPU per group4 vCPU
Max memory per group16 GB
BillingPer second of CPU + memory
PersistenceNone by default — use Azure Files for persistent storage

Container Groups

A container group is a collection of containers that run on the same host, share the same lifecycle, network, and storage. This is ACI equivalent of a Kubernetes pod.

  • Containers in a group share the same IP address and port namespace
  • They can communicate via localhost
  • All containers in a group start and stop together
  • Common pattern: app container + sidecar (logging, proxy, metrics)

Restart Policies

PolicyBehaviourUse For
AlwaysAlways restart — even on successLong-running services, web apps
NeverNever restart — run once and stopOne-time jobs, batch tasks
OnFailureRestart only if container exits with non-zero codeJobs that should retry on failure but stop on success

Networking

  • Public IP — ACI can expose a public IP address with a DNS name label
  • DNS name — Custom DNS label: mycontainer.centralindia.azurecontainer.io
  • VNet integration — Deploy ACI into a VNet subnet for private access
  • Port exposure — Specify which ports to expose publicly

Persistent Storage

ACI containers are ephemeral by default — storage is lost when the container stops. For persistent data, mount an Azure Files share:

Azure CLIMount Azure Files in ACI
az container create \
  --resource-group myRG \
  --name mycontainer \
  --image myregistry.azurecr.io/myapp:v1 \
  --azure-file-volume-account-name mystorageaccount \
  --azure-file-volume-account-key $STORAGE_KEY \
  --azure-file-volume-share-name myshare \
  --azure-file-volume-mount-path /data

Creating ACI via CLI

Azure CLICreate and manage container instances
# Create a simple public container
az container create \
  --resource-group myRG \
  --name mywebcontainer \
  --image nginx:latest \
  --dns-name-label mywebapp-2026 \
  --ports 80 \
  --cpu 1 \
  --memory 1.5

# Create from private ACR
az container create \
  --resource-group myRG \
  --name myappcontainer \
  --image myregistry.azurecr.io/myapp:v1 \
  --registry-login-server myregistry.azurecr.io \
  --registry-username $SP_APP_ID \
  --registry-password $SP_PASSWORD \
  --dns-name-label myapp-2026 \
  --ports 3000 \
  --restart-policy OnFailure \
  --environment-variables NODE_ENV=production

# View container logs
az container logs --resource-group myRG --name myappcontainer

# View container status
az container show \
  --resource-group myRG \
  --name myappcontainer \
  --query instanceView.state

# Delete container
az container delete --resource-group myRG --name myappcontainer --yes

When to Use ACI

Good fit for ACINot a good fit — use AKS or Container Apps
Batch jobs and one-time tasksHigh-traffic production services needing auto-scale
CI/CD pipeline stepsMicroservices needing service discovery
Dev/test containersStateful workloads needing complex storage
Event-driven short tasksApplications requiring rolling deployments
Simple web apps with predictable loadMulti-container apps with complex dependencies
💡
AZ-104 Exam Tip Know the three restart policies (Always, Never, OnFailure). Know that ACI containers are ephemeral — use Azure Files for persistence. Know that a container group shares a network namespace. Know ACI is billed per second of CPU and memory — it scales to zero cost when stopped.
📝 Practice Questions
Click an option to check your answer.
Q1. Which ACI restart policy should you use for a batch job that should retry on failure but stop when it succeeds?
A — Always
B — Never
C — OnFailure
D — OnSuccess
Q2. What is a Container Group in Azure Container Instances?
A — Multiple containers running across different hosts
B — Multiple containers on the same host sharing the same IP, lifecycle, and storage
C — A collection of ACI instances across an Azure region
D — A grouping of container images in Azure Container Registry
Q3. ACI container storage is lost when the container stops. What should you use to persist data?
A — Azure Blob Storage
B — Azure Files share mounted into the container
C — Azure Table Storage
D — Local disk on the container host
Q4. How is Azure Container Instances billed?
A — Per hour regardless of usage
B — Per second of CPU and memory used — billing stops when container stops
C — Per execution (like Azure Functions)
D — Free — ACI has no compute charges
Q5. Which scenario is ACI best suited for?
A — A high-traffic e-commerce API requiring auto-scaling and rolling deployments
B — A nightly batch processing job that runs for 30 minutes then stops
C — A complex microservices application with 20 services requiring service discovery
D — A persistent database that must run 24/7 with complex storage requirements
Comments
Disclaimer: RedKite Cloud is an independent educational resource and is not affiliated with Microsoft Corporation.