Azure Container Instances
Serverless container execution: run a container without provisioning VMs or clusters, billed per second, ideal for burst, CI, and scheduled jobs.
Why
ACI is the fastest way to run a container in Azure — no cluster, no VM, just az container create. It bills per second of CPU/memory used, so it is cheaper than an always-on VM for short jobs.
It supports virtual nodes in AKS for burst overflow.
When
Use ACI for one-off tasks (data processing, DB migrations), CI build steps, scheduled jobs (with Logic Apps timer), or AKS burst overflow via virtual nodes. Avoid for long-running services — App Service or AKS is cheaper for always-on workloads since ACI bills continuously.
How
Example
Common Problems
- ⚠Container exits immediately with code 0 — the command finished; check az container logs to confirm it did the work, and use --restart-policy Never so ACI does not retry.
- ⚠Image pull fails from ACR — credentials not passed or identity lacks AcrPull; use --acr-identity to assign a managed identity with AcrPull role.
- ⚠Long-running container is expensive — ACI bills per second always-on; move to App Service or AKS for services that run 24/7.
Best Practices
- ✓Use --restart-policy Never for batch jobs and poll az container show for the terminal state; use Always only for services you intend to keep running.
- ✓Assign a managed identity to the container group instead of passing secrets as env vars — the identity can access Key Vault, Storage, and ACR via RBAC.
- ✓For bursty AKS workloads, enable the virtual node (ACI) and let KEDA/HPA schedule overflow pods onto ACI, paying only when they run.
FAQ
What is Azure Container Instances and what problem does it solve?
Serverless container execution: run a container without provisioning VMs or clusters, billed per second, ideal for burst, CI, and scheduled jobs. It lets developers deploy, store, and scale without self-managing infrastructure — a core reference for cloud service selection.
How do I get started with Azure Container Instances in 5 minutes?
Two steps to run it: (1) Have a container image in ACR or a public registry.; (2) Run az container create with the image, CPU/memory, and optional env vars and ports.. Validate on the free tier first, then wire into production.
What is the #1 pitfall with Azure Container Instances?
The most frequent issue is: Container exits immediately with code 0 — the command finished; check az container logs to confirm it did the work, and use --restart-policy Never so ACI does not retry.. Run a pre-launch checklist item by item, and add policy/config scanning in CI.
What are the best practices for Azure Container Instances?
Best practices for Azure Container Instances include: Use --restart-policy Never for batch jobs and poll az container show for the terminal state; use Always only for services you intend to keep running.; Assign a managed identity to the container group instead of passing secrets as env vars — the identity can access Key Vault, Storage, and ACR via RBAC.; For bursty AKS workloads, enable the virtual node (ACI) and let KEDA/HPA schedule overflow pods onto ACI, paying only when they run.. The first one — "Use --restart-policy Never for batch jobs and poll az container show for the terminal state; use Always only for services you intend to keep running." — should be a team default baked into your IaC templates.
How do I control cost and avoid bill surprises with Azure Container Instances?
Three ways to prevent overspend: (1) tag every resource with env/team and enable billing alarms; (2) set budget thresholds to trigger Slack/email alerts; (3) review idle resources in Cost Explorer regularly and clean them up. Most Azure Container Instances options offer a free tier — validate within free quota before scaling.