Resource Group Tags

Tags are a further method of logically grouping resources and resource groups. For example for can give resources in different resource groups the same tag to help with billing and general management.

Tags consist of a name and a value.

Tag Rules;

  • Tags are not inherited, i.e a tag applied to a resource group does not filter down to the groups members.
  • Names can’t contain special characters <,>,%,&,\,?,/
  • You can have up to 15 tags
  • The tag name is limited to 512 characters
  • The tag value is limited to 256 characters

Viewing and adding Tags via the portal

Navigate to the resource group select Tags and enter the required name and value.

Using PowerShell to list a Resource Groups Tags

(Get-AzureRmResourceGroup -name 'myorg-app1-rg').Tags

Using PowerShell to add a Tag to a resource group

When you add an additional tag using PowerShell you actually replace all of the current tags with your new tag. Instead of jumping straight into using the Set-AzureRmResourceGroup -Tag command we generally want store the our current tags in a variable and append our new tag. That way we can preserve all of the current tags.

#Store the current tags in the variable tags
$tags = (Get-AzureRmResourceGroup -name 'myorg-app1-rg').Tags 

#Append our new tag to the tags variable. Our new tag has the name CostCentre and the value HumanResources
$tags.Add("CostCentre", "HumanResources")

#Set the resources groups tags to equal the contents of our tags varible
Set-AzureRmResourceGroup -Tag $tags -Name 'myorg-app1-rg'

Using AzureCLI to list a Resource Groups Tags

az group show -n myorg-app1-rg --query tags

Using AzureCLI to add a Resource Groups Tag

az group update -n myorg-app1-rg --set tags.CostCentre=HumanResources