Resource Tagging in Azure


Tagging in Microsoft Azure or in the cloud generally is useful when you operate a number of resources. By applying metadata to logically organize and manage resources in an easy way, since tags are just additional metadata or attributes associated with Microsoft Azure ARM (Azure Resource Manager) resources.

Tag assignment

Tags can be specifically be assigned individual resources like storage accounts, virtual machines, or Resource Groups. Resource groups organize related resources to facilitate management, but when a Resource Group is assigned a tag its only assigned to the Resource Group and not its child resources. So bare in mind that child resources within a Resource Group not inherit tags.

Tag example

Tags consists of Key → Value pairs that we can assign to resources, for instance project, owner, department and life cycle phase tag. You give the tag a Key and a suitable value, which you can use to filter later on. A resource can have up to 15 tags, it’s therefore important to have a concise and consistent naming standard for your tags. In other words, do not use tags that don’t provide any useful information. Below is an example of the result of a tagged resource.

Why do we tag Resources?

Tagging let you organize deployed Azure resources. For instance we can use tags when it comes to things like:

  • Search by a specific tag, let’s say we want to find all resources tagged with Department → IT.
  • It facilitates viewing of related resources, for instance you like a list of Stage servers vs. Production servers.
  • It facilitates billing and cost management, overview of different projects and customers as well.
  • Allows automation and bulk actions, for instance “shutdown all VMs with the tag LifeCyclePhase → Stage

Tag restriction:

When creating resource tags, there is some limitations or restriction to consider:

  • A resource can have a maximum of 15 tags
  • A Resource Group can have a maximum of 15 key/pairs
  • A tag name is restricted to 512 characters and tag value is restricted to 256 characters.
  • Tags applied to a Resource Group is not inherited by the resources within the Resource Group
  • Tags cannot be applied to classic resources, such as Cloud Services.
  • Tag names cannot contain the following characters <,>,%,&,,?,/

Tag Management

Tags can be managed in the Azure Portal, but only after a resource is created. You can also manage tags from Azure PowerShell and Azure CLI. When I learned about it, I thought I create some scripts for managing tags, just to get some hands on experience. It ended up with a script for getting, adding and removing tags. It ended with the following scripts:


In this script, I use the cmdlet Get-AzResource and wrapped it with parenthesis and selected the property tags, to list the properties to the resource specified in the parameter $ResourceName and $ResourceGroupNamee. I also used Write-Verbose to be able to see what the function does when it is runs, by this can be called by adding -Verbose in the function call, for instance


To add a tag to an Azure Resource you can use the cmdlet Set-AzResource , this cmdlet takes Resource Name or Resource id, Resource Group, and a hash table as input to create a key→value pair tag. The first thing I did was to create an advanced PowerShell function, which comes with many great features such as verbose and debug, and then creating the necessary parameters (for my needs).


To remove the tags from a resource you can simple just add an empty hash table, then it will overwrite all existing tags.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fredrik Engseth

Fredrik Engseth

Consultant | Developer | Dynamics 365 | Power Platform | Azure