0
0
Azurecloud~5 mins

Container services comparison in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Running apps in containers helps keep them neat and easy to move. Azure offers different container services to run your apps smoothly without managing servers yourself.
When you want to run a simple container app quickly without managing servers.
When you need to run many containers that can grow or shrink automatically.
When you want to run containers alongside other Azure services with easy integration.
When you want to manage container clusters with full control over scaling and updates.
When you want to run containers on virtual machines you manage yourself.
Commands
This command creates a simple Azure Container Instance to run a container quickly without managing servers.
Terminal
az container create --resource-group example-group --name mycontainer --image mcr.microsoft.com/azuredocs/aci-helloworld --dns-name-label mycontainerexample --ports 80
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-group/providers/Microsoft.ContainerInstance/containerGroups/mycontainer", "location": "eastus", "name": "mycontainer", "properties": { "containers": [ { "name": "mycontainer", "properties": { "image": "mcr.microsoft.com/azuredocs/aci-helloworld", "ports": [ { "port": 80 } ], "resources": { "requests": { "cpu": 1.0, "memoryInGb": 1.5 } }, "instanceView": { "state": "Running" } } } ], "ipAddress": { "dnsNameLabel": "mycontainerexample", "ports": [ { "port": 80, "protocol": "TCP" } ], "type": "Public" }, "provisioningState": "Succeeded" }, "type": "Microsoft.ContainerInstance/containerGroups" }
--resource-group - Specifies the Azure resource group to use
--image - Specifies the container image to run
--dns-name-label - Creates a public DNS name for the container
This command creates an Azure Kubernetes Service cluster with two nodes for managing container clusters with scaling and updates.
Terminal
az aks create --resource-group example-group --name myAKSCluster --node-count 2 --enable-managed-identity --generate-ssh-keys
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-group/providers/Microsoft.ContainerService/managedClusters/myAKSCluster", "location": "eastus", "name": "myAKSCluster", "properties": { "provisioningState": "Succeeded", "kubernetesVersion": "1.26.0", "agentPoolProfiles": [ { "count": 2, "name": "nodepool1", "vmSize": "Standard_DS2_v2" } ] }, "type": "Microsoft.ContainerService/managedClusters" }
--node-count - Sets the number of nodes in the cluster
--enable-managed-identity - Enables secure identity management for the cluster
This command downloads the access credentials to connect to the AKS cluster using kubectl.
Terminal
az aks get-credentials --resource-group example-group --name myAKSCluster
Expected OutputExpected
Merged "myAKSCluster" as current context in /home/user/.kube/config
--resource-group - Specifies the resource group of the AKS cluster
--name - Specifies the AKS cluster name
This command lists the nodes in the AKS cluster to verify the cluster is running and nodes are ready.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION aks-nodepool1-12345678-vmss000000 Ready agent 5m v1.26.0 aks-nodepool1-12345678-vmss000001 Ready agent 5m v1.26.0
Key Concept

If you remember nothing else from this pattern, remember: Azure Container Instances are for quick single containers, while Azure Kubernetes Service is for managing many containers with scaling and control.

Common Mistakes
Trying to use Azure Container Instances for complex multi-container apps needing scaling.
ACI is designed for simple, single-container apps and does not support advanced orchestration.
Use Azure Kubernetes Service (AKS) for multi-container apps that need scaling and orchestration.
Not downloading AKS credentials before running kubectl commands.
Without credentials, kubectl cannot connect to the AKS cluster and commands fail.
Run 'az aks get-credentials' to configure kubectl access before managing the cluster.
Summary
Use 'az container create' to run a quick container with Azure Container Instances.
Use 'az aks create' to set up a Kubernetes cluster for managing many containers.
Download AKS credentials with 'az aks get-credentials' before using kubectl to manage the cluster.
Use 'kubectl get nodes' to check the status of your AKS cluster nodes.