Use tags to organize your Azure resources (with the Azure CLI)!

MVP

 

Hi Azure friends,

 

Start the CloudShell in the Azure portal or go to the following URL: https://shell.azure.com/

Please start with the following steps to begin the deployment (the Hashtags are comments):

 

#Here you can find out which subscription you are working with
az account show

 

#View all subscriptions
az account list --all --output table

 

#change the subscription (if necessary)
az account set --subscription "Name of the Subscription"

 

# To overwrite the tags on a resource
az resource tag --tags 'Dept=IT' 'Environment=Test' -g tw-rg01 -n vnet-base --resource-type "Microsoft.Network/virtualNetworks"

 

# To append a tag to the existing tags on a resource
az resource update --set tags.'Status'='Approved' -g tw-rg01 -n vnet-base --resource-type "Microsoft.Network/virtualNetworks"

 

# To overwrite the existing tags on a resource group
az group update -n tw-rg01 --tags 'Environment=Test' 'Dept=IT'

 

# To append a tag to the existing tags on a resource group
az group update -n tw-rg01 --set tags.'Status'='Approved'

 

# To see the existing tags for a resource
az resource show -n vnet-base -g tw-rg01 --resource-type "Microsoft.Network/virtualNetworks" --query tags

 

# To see the existing tags for a resource group
az group show -n tw-rg01 --query tags

 

# To get all the resources that have a particular tag and value
az resource list --tag Dept=Finance

 

# To get resource groups that have a specific tag
az group list --tag Dept=IT

 

Now you have organized Azure Tags with the Azure CLI! Congratulations!

 

I hope this article was useful. Best regards, Tom Wechsler

 

P.S. All scripts (#PowerShell, @azure CLI, #Terraform, #ARM) that I use can be found on github! https://github.com/tomwechsler

1 Reply

So after organzing, how do we delete the multiple Resource groups having these tags using Azure CLI