Microsoft Azure Documentation

Sign In

Deploy Container Instances to Azure

Quickly run containers in Azure without managing servers.

Introduction to Azure Container Instances (ACI)

Azure Container Instances (ACI) offers the fastest and simplest way to run a container in Azure. It allows you to deploy a container without having to manage any virtual machines or become an expert in orchestrators. ACI is a great solution for scenarios that can be modeled as containers, such as:

  • Simple applications or line-of-business apps
  • Development and test scenarios
  • Building and testing applications
  • Simple microservices

Information: ACI is ideal for quick deployments and simple workloads. For more complex orchestrations, consider Azure Kubernetes Service (AKS).

Deploying Containers using the Azure CLI

The Azure CLI provides a powerful command-line interface for deploying and managing Azure resources, including Container Instances.

Azure CLI
Azure PowerShell

1. Log in to Azure

Ensure you are logged in to your Azure account:

az login

2. Create a Resource Group

If you don't have one already, create a resource group to hold your ACI instance:

az group create --name myResourceGroup --location eastus

3. Deploy a Container Instance

Deploy a simple container, for example, `mcr.microsoft.com/azuredocs/aci-helloworld`, to your resource group:

az container create --resource-group myResourceGroup --name myACI --image mcr.microsoft.com/azuredocs/aci-helloworld --dns-name-label myhelloworldapp --ports 80

Once the deployment is complete, you can find the fully qualified domain name (FQDN) of your container instance:

az container show --resource-group myResourceGroup --name myACI --query "{FQDN:ipAddress.fqdn}" --output tsv

You can then access your running container by navigating to the FQDN in a web browser.

1. Log in to Azure

Ensure you are logged in to your Azure account:

Connect-AzAccount

2. Create a Resource Group

If you don't have one already, create a resource group to hold your ACI instance:

New-AzResourceGroup -Name "myResourceGroup" -Location "East US"

3. Deploy a Container Instance

Deploy a simple container, for example, `mcr.microsoft.com/azuredocs/aci-helloworld`, to your resource group:

New-AzContainerGroup -ResourceGroupName "myResourceGroup" -Name "myACI" -Image "mcr.microsoft.com/azuredocs/aci-helloworld" -DnsNameLabel "myhelloworldapp" -Port 80

Once the deployment is complete, you can find the fully qualified domain name (FQDN) of your container instance:

(Get-AzContainerGroup -ResourceGroupName "myResourceGroup" -Name "myACI").IpAddress.Fqdn

You can then access your running container by navigating to the FQDN in a web browser.

Deploying Containers using the Azure Portal

The Azure portal provides a user-friendly graphical interface for deploying and managing your container instances.

  1. Sign in to the Azure portal.
  2. In the search bar, type "Container instances" and select it from the results.
  3. Click + Create.
  4. On the Basics tab:
    • Select your Subscription and an existing or new Resource group.
    • Enter a Container name (e.g., `myportalcontainer`).
    • Choose a Container image (e.g., `mcr.microsoft.com/azuredocs/aci-helloworld`).
    • Set the OS type (Linux or Windows).
    • You can optionally set a DNS name label to make your container accessible via a public FQDN.
    • Configure the Ports your container needs to expose.
  5. Navigate through the other tabs (Networking, Advanced, Tags) as needed, or accept the defaults.
  6. Click Review + create and then Create.

Once deployed, you can access the container's FQDN from its overview page in the portal.

Deploying Containers using ARM Templates

Azure Resource Manager (ARM) templates allow you to define your infrastructure as code, enabling repeatable and consistent deployments. Here's a simple ARM template for deploying a container instance:


{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "containerGroupName": {
            "type": "string",
            "defaultValue": "myArmContainer",
            "metadata": {
                "description": "Name of the container group"
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "eastus",
            "metadata": {
                "description": "Location for the container group"
            }
        },
        "containerImage": {
            "type": "string",
            "defaultValue": "mcr.microsoft.com/azuredocs/aci-helloworld",
            "metadata": {
                "description": "Container image to deploy"
            }
        },
        "dnsNameLabel": {
            "type": "string",
            "defaultValue": "myarmhelloworldapp",
            "metadata": {
                "description": "DNS name label for the container group"
            }
        },
        "ports": {
            "type": "array",
            "defaultValue": [80],
            "metadata": {
                "description": "Ports to expose on the container group"
            }
        }
    },
    "resources": [
        {
            "type": "Microsoft.ContainerInstance/containerGroups",
            "apiVersion": "2021-10-01",
            "name": "[parameters('containerGroupName')]",
            "location": "[parameters('location')]",
            "properties": {
                "containers": [
                    {
                        "name": "[parameters('containerGroupName')]",
                        "properties": {
                            "image": "[parameters('containerImage')]",
                            "ports": {
                                "port": "[first(parameters('ports'))]"
                            },
                            "resources": {
                                "requests": {
                                    "cpu": 1.0,
                                    "memoryInGB": 1.5
                                }
                            }
                        }
                    }
                ],
                "osType": "Linux",
                "ipAddress": {
                    "type": "Public",
                    "ports": "[parameters('ports')]",
                    "dnsNameLabel": "[parameters('dnsNameLabel')]"
                }
            }
        }
    ],
    "outputs": {
        "containerGroupFqdn": {
            "type": "string",
            "value": "[list('[parameters('containerGroupName')]', resourceGroup().id).fqdn]"
        }
    }
}
                

To deploy this template using the Azure CLI:


az deployment group create --resource-group myResourceGroup --template-file azuredeploy.json