Overview
This guide will walk you through deploying a containerized application to Azure Container Instances (ACI) using the Azure CLI. ACI allows you to run containers in Azure without managing virtual machines or orchestrators.
Prerequisites
- An Azure subscription. Create a free account.
- Azure CLI installed. If you don't have it, install it now.
Steps
Sign in to Azure
Open your terminal or command prompt and sign in to your Azure account:
az login
Follow the instructions to authenticate.
Create a resource group
A resource group is a logical container for your Azure resources. Create one for this quickstart:
az group create --name myResourceGroup --location eastus
myResourceGroup with a unique name and eastus with your preferred Azure region.
Deploy a container
Use the az container create command to deploy a simple container. This example deploys a container running the Azure CLI sample image:
az container create --resource-group myResourceGroup --name myaci-container --image mcr.microsoft.com/azuredocs/aci-helloworld --dns-name-label myaci-helloworld --ports 80
This command does the following:
--resource-group: Specifies the resource group created in the previous step.--name: Assigns a name to your container instance.--image: Specifies the Docker image to use.--dns-name-label: Creates a public DNS name for the container.--ports: Exposes port 80 on the container.
Upon successful deployment, you will see output similar to this:
Verify the deployment
You can verify the deployment by browsing to the FQDN (Fully Qualified Domain Name) of your container. Find the FQDN in the output from the previous step or by running:
az container show --resource-group myResourceGroup --name myaci-container --query "{FQDN:ipAddress.fqdn}" --output tsv
Open this FQDN in your web browser. You should see a message like "Hello World!" indicating your container is running.
Clean up resources
To avoid incurring further charges, delete the resource group and all its resources when you are finished:
az group delete --name myResourceGroup --yes --no-wait
This command deletes the resource group and all resources within it. The --yes flag confirms the deletion, and --no-wait allows the command to return immediately while the deletion happens in the background.
Next Steps
Congratulations! You have successfully deployed a container to Azure Container Instances. To learn more, explore the following resources: