Azure Container Instances (ACI)
Azure Container Instances (ACI) provides the fastest and simplest way to run a container in Azure. It enables you to run containers without managing any virtual machines or orchestrators.
ACI is a service that allows you to deploy containers as a single unit of deployment. Each container group has its own CPU, memory, and networking resources. This makes it ideal for a wide range of scenarios, from simple web applications to complex event-driven workloads.
Getting Started with ACI
Getting started with ACI is straightforward. You can deploy containers using the Azure portal, Azure CLI, or Azure SDKs.
Using Azure CLI
Here's a quick example of deploying a simple container using the Azure CLI:
az container create \
--resource-group MyResourceGroup \
--name myaci \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--dns-name-label myaci-helloworld \
--ports 80
This command creates a container group named myaci using the aci-helloworld image and exposes port 80.
Azure Portal
The Azure portal provides a graphical interface for creating and managing container instances. Navigate to "Container Instances" and follow the guided creation process.
Key Features
- Serverless Containers: No infrastructure to manage.
- Fast Deployment: Start your containers in seconds.
- Per-Second Billing: Pay only for the CPU and memory you consume.
- Rich Configuration: Configure CPU, memory, environment variables, volumes, and networking.
- Integration: Integrates with other Azure services like Azure Kubernetes Service (AKS), Azure Logic Apps, and Azure Functions.
Common Use Cases
- Web Apps: Deploy single-container web applications.
- Event-Driven Processing: Run tasks triggered by events.
- Batch Jobs: Execute short-lived batch workloads.
- Development and Testing: Quickly spin up containers for development or testing.
- Build Agents: Use ACI as a build agent for CI/CD pipelines.
Networking
Each container group in ACI is assigned a public IP address and a fully qualified domain name (FQDN) by default, allowing direct access to your applications.
You can also configure virtual network integration to allow your container instances to securely access resources within your Azure Virtual Network.
DNS Name Label
When you create a container group with a public IP address, you can assign a DNS name label. This creates a DNS record of the form <dns-name-label>.<region>.azurecontainer.io.
Storage
ACI supports mounting several types of volumes:
- Azure File Shares: Mount an Azure File Share to provide persistent, shared storage for your containers.
- Empty Dir: An ephemeral volume that exists for the lifetime of the container group.
- Secret Volumes: Mount Kubernetes secrets or Azure Key Vault secrets as volumes.
Monitoring and Logging
ACI integrates with Azure Monitor to provide insights into your container's performance and health.
You can stream logs from your container group directly to Azure Log Analytics or other destinations for detailed analysis.
# Example command to view logs
az container logs --resource-group MyResourceGroup --name myaci
Pricing
ACI pricing is based on the vCPU and memory resources consumed by your container instances, billed per second. There are no minimum charges or upfront costs.
Visit the Azure Container Instances pricing page for detailed information.
Frequently Asked Questions (FAQ)
What is a container group?
A container group is the smallest deployable compute resource in Azure Container Instances. It's a collection of one or more containers that share the same compute and networking resources, and are deployed together on the same host machine.
Can I run Docker Compose with ACI?
Yes, you can use the aci-compose tool or deploy multi-container applications defined by Docker Compose files to ACI.
What operating systems are supported?
ACI supports Linux and Windows container images.