Skip to content

Instantly share code, notes, and snippets.

@inchoate
Created May 12, 2023 21:00
Show Gist options
  • Save inchoate/34beefd3a204187b9522d5e4ddb50393 to your computer and use it in GitHub Desktop.
Save inchoate/34beefd3a204187b9522d5e4ddb50393 to your computer and use it in GitHub Desktop.
Bugs in the Azure CLI

I found a bug in Azure's az CLI when it parses variables.

I was tagging a lot of resources and initially did this:

export ENV=demo
export VERSION=
export RG=rg-apps-${ENV}${VERSION}
export LOCATION=eastus
export SUBSCRIPTION="my-subscription-id"
export TENANT_ID=$(az account show --query tenantId -o tsv)
export DOMAIN=strongholdresourcepartners.com

# Now, set TAGS, but notice how I added the flag in the variable. az doesn't care for that
export TAGS="--tags env=${ENV} owner=technology business_unit=technology"

# add a nodepool to the cluster I made in the previous step:
az aks nodepool add --name userpool \
    --resource-group ${RG} \
    --cluster-name ${CLUSTER} \
    --node-count 1 \
    --enable-cluster-autoscaler \
    --min-count 1 \
    --max-count 6 \
    --node-vm-size Standard_D2s_v3 \
    ${TAGS} \
    --zones 1 2 \
    --mode User \

But this would fail with an error complaining about not supporting the tags flag on the CLI. But, az aks nodepool add -h clearly shows that it takes --tags. This also happened in a bunch of other commands -- BUT NOT ALL of them which made this a little confusing.

The solution is to do this, instead:

# Now, set TAGS, but notice how I added the flag in the variable. az doesn't care for that
export TAGS="env=${ENV} owner=technology business_unit=technology"

# add a nodepool to the cluster I made in the previous step:
az aks nodepool add --name userpool \
    --resource-group ${RG} \
    --cluster-name ${CLUSTER} \
    --node-count 1 \
    --enable-cluster-autoscaler \
    --min-count 1 \
    --max-count 6 \
    --node-vm-size Standard_D2s_v3 \
    --tags ${TAGS} \
    --zones 1 2 \
    --mode User \

az is your friend again if you this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment