How to find the default AKS version using Bash and PowerShell

1 minute read

I always wondered how the default AKS version was selected via the Azure portal until I recently read this in the docs:

When you deploy an AKS cluster with Azure portal, Azure CLI, Azure PowerShell, the cluster defaults to the N-1 minor version and latest patch. For example, if AKS supports 1.17.a, 1.17.b, 1.16.c, 1.16.d, 1.15.e, and 1.15.f, the default version selected is 1.16.c.

Even though there are ways to auto-upgrade existing AKS clusters I typically use Terraform to provision clusters, so I prefer to have more control over what version to use - and more importantly - when the upgrades occur.

Read on to see Bash and PowerShell examples for showing the default AKS version via the command-line.

Show the default AKS version using Bash

# show all aks versions
az aks get-versions --location 'uksouth'

# show default aks version using a JMESPath query
# https://learn.microsoft.com/en-us/cli/azure/query-azure-cli?tabs=concepts%2Cbash
az aks get-versions --location 'uksouth' --output 'tsv' --query 'orchestrators | [?default].orchestratorVersion'

# show default aks version using jq
az aks get-versions --location 'uksouth' | jq -r '.orchestrators | .[] | select(.default==true) | .orchestratorVersion'

Show the default AKS version using PowerShell

# show all aks versions
Get-AzAksVersion -location 'uksouth'

# show default aks version
(Get-AzAksVersion -location 'uksouth' | Where-Object default).OrchestratorVersion

# show default aks version using az cli
((az aks get-versions --location 'uksouth' | ConvertFrom-Json).orchestrators | Where-Object default).OrchestratorVersion

Leave a comment