Course contentsShow
← Cloud and Infrastructure
Lesson 1493 of 2,98930. Managed Kubernetes ServicesFree lesson

Creating an AKS Cluster with Azure CLI

Using az aks create command to provision clusters programmatically with configuration options.

Creating an AKS Cluster with Azure CLI

You'll learn how to provision an Azure Kubernetes Service cluster programmatically using the az aks create command with key configuration options.

Why Use Azure CLI?

While the Azure Portal provides a visual interface (as you learned in the previous lesson), the Azure CLI allows you to script, automate, and version-control your AKS cluster creation. Think of it like ordering from a menu versus following a recipe—both get you food, but recipes are repeatable and customizable.

The Core Command

The az aks create command is your primary tool for provisioning AKS clusters programmatically. At minimum, you need:

az aks create \
  --resource-group myResourceGroup \
  --name myAKSCluster \
  --node-count 3 \
  --generate-ssh-keys

This creates a cluster with three nodes in the specified resource group and generates SSH keys for node access.

Important Configuration Options

You can customize your cluster with additional parameters:

  • --node-vm-size: Set the VM size for nodes (e.g., Standard_DS2_v2)
  • --kubernetes-version: Specify the Kubernetes version
  • --enable-managed-identity: Enable system-assigned managed identity
  • --network-plugin: Choose between azure or kubenet CNI
  • --node-resource-group: Name the auto-created node resource group

Example with options:

az aks create \
  --resource-group myResourceGroup \
  --name myAKSCluster \
  --node-count 2 \
  --node-vm-size Standard_D4s_v3 \
  --kubernetes-version 1.27.7 \
  --enable-managed-identity \
  --generate-ssh-keys

Key Takeaway: The az aks create command provides a scriptable, repeatable way to provision AKS clusters with precise control over configuration, making it ideal for infrastructure-as-code workflows and automated deployments.