Prerequisites

  • Use the Bash environment in Azure Cloud Shell.
  • For installing azure cli on local refer following link to access the resoures using the azure-cli.

Step 1: Create a resource group

Container instances must be deployed into a resource group in a manner similar to other Azure resources. Resource groups can be used to manage and arrange related Azure resources.

az group create --name myResourceGroup --location eastus

Step 2: Create A Container

Using the Azure CLI command az container create, a container instance must be created in this stage. Using the Docker image “mcr.microsoft.com/azuredocs/aci-helloworld,” this command establishes a container with the name “mycontainer” in the designated Azure resource group (“myResourceGroup”). It also gives the container the DNS name label “aci-demo” and opens port 80 to network traffic.

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

To obtain information about a particular container instance, use the az container display command. Here, it obtains details about the “mycontainer” container, which is housed in the “myResourceGroup” resource group. The Fully Qualified Domain Name (FQDN) and Provisioning State are properties that are exhibited in a table format using the –out table option. The attributes to display are specified by the –query argument.

az container show --resource-group myResourceGroup --name mycontainer 
--query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}" --out table

Step 3: Pull The Container Logs

The command listed below can be used to get the logs for a particular container instance. Here, it obtains the logs from the “mycontainer” container, which is housed in the “myResourceGroup” resource group. When the containerized application is operating within the container instance, this command can be useful for monitoring and troubleshooting it.

az container logs --resource-group myResourceGroup --name mycontainer

Step 4: Attach output streams

Real-time communication with a container is possible by attaching its standard input, output, and error streams to the local terminal using the az container attach command. Here, it affixes to the “mycontainer” container inside the “myResourceGroup” resource group. The behavior of the containerized application operating within the container instance can be seen and debugged with the help of this command.

az container attach --resource-group myResourceGroup --name mycontainer

Step 5: Clean up resources

To remove a container instance, use the az container delete command. In this instance, it removes the “mycontainer” container instance from the resource group “myResourceGroup.” The container instance and its related resources are permanently removed from the Azure environment by using this command.

az container delete --resource-group myResourceGroup --name mycontainer

To list every container instance inside a given resource group, use the az container list command. Here, it outputs the data in a tabular manner and lists the container instances in the “myResourceGroup” resource group. An overview of the container instances deployed in the designated resource group is given by this command, together with pertinent details like IP address, name, image, and status.

az container list --resource-group myResourceGroup --output table

People Also Ask

How To Create Azure Virtual Machines

Read

How To Create Azure Virutal Network

Read

How To Deploy A Container To Azure Container Instances ?

In layman’s terms, how will it feel when a developer develops an app and a member of the testing team tries to test the application on his/her OS? They will have to install the packages, and libraries required to run the app. Well, in this case, the container makes it easy and faster to rapidly deploy and scale applications. The container provides an auto-scaling feature, when your containerized app gets more traffic, it scales up.

Similar Reads

What is Azure Container Instances?

Microsoft Azure provides many services, and Azure Container Instances (ACI) is one of them. This service helps to run and manage containers and applications without managing the virtual machines. Using ACI, containers can get started within a few seconds without deploying or managing virtual machines. For deploying images, we can use the provided images (Linux and Windows from Docker Hub), the Azure container registry, or another image registry. We can specify the CPU and memory required as per the use. This service uses a Pay-as-you-go pricing model....

Sign in to Azure

Access the Azure portal by signing in with your credentials. If you’re new to Azure, sign up for a free account before proceeding with the steps....

Create a container instance | Step-By-Step Tutorial

Step 1: Begin by logging in to your Azure portal. Then, navigate to the “Create Resource” option to initiate the resource creation process professionally....

View container logs

Examining the logs of a container instance proves invaluable for diagnosing potential issues with either the container itself or the application it hosts....

Clean up resources

To ensure proper cleanup and resource management, it’s important to delete container instances that are no longer needed. This helps free up resources and avoid unnecessary costs associated with running idle or unused instances....

Deploying Containers with Azure Container Instances: Real-World Use Cases

Web Applications: Host web applications in containers on ACI for easy deployment and scalability. Microservices Architecture: Deploy microservices as individual containers on ACI to achieve better isolation and scalability. CI/CD Pipelines: Use ACI to run containerized CI/CD pipelines, allowing for quick and efficient testing and deployment of applications. Batch Processing: Run batch processing tasks in containers on ACI to handle periodic or one-time compute-intensive workloads. Dev/Test Environments: Provision temporary development or testing environments by deploying containers on ACI, reducing setup time and resource usage....

Steps To Deploy a Container to Azure Container Instances Using Azure CLI

Follown the steps mentioned below to Deploy a Container to Azure Container Instances Using Azure CLI....

Prerequisites

Use the Bash environment in Azure Cloud Shell. For installing azure cli on local refer following link to access the resoures using the azure-cli....

Azure Container Instances – FAQ’s

What Is A Container Registry, And Why Do We Need It?...