Azure Resource Tags

Azure Resource Tags can assist you in organising your Azure subscription, including billing! Running all your workloads from Development to Production on the one subscription? Resource tags will be beneficial to organise the structure between these different environments!

Further uses of Resource Tags may be to group resources per department or team? As mentioned above, can be handy for billing as well if various departments are billed differently!

Azure Resource Tags do have some limitations:

  • Not all Azure Resources support tagging – although any resource that can be deployed via ARM is supported
  • A resource or resource group can have up to 15 tags associated
  • Tag name limit of 512 characters
  • Tag value limited to 256 characters (Storage account tag limit is 128 characters)
  • Tags cannot be applied to classic resources

Lets get Tagging!

Tagging a resource in the Portal

In this example, I will look at having a Tag name: environment with two tag values: prd & dev

Select a resource that supports tagging, see above for the list of available supported resources

I will tag a Virtual Machine, VM: tamops is now selected

On the left-side menu – select Tags

If a Tag Name has already been created it will be in the drop down menu, if not it can also be created in this window.
Enter Name & Value then select Save

You have successfully added a Resource Tag, straightforward but can be a tedious approach if you are looking to manually tag several resources, lets look at the PowerShell alternative!

Tagging multiple resources using PowerShell

Apply the Resource Tag Name: environment & value: prd to the Resource Group

$ResourceGroup = Get-AzureRMResourceGroup -name "tamops-tagging"
$TagName = "environment"
$TagValue = "prd"

Set-AzureRMResourceGroup -Name $ResourceGroup.ResourceGroupName -Tag @{ $TagName="$TagValue" }

Lets now apply this Resource Group Tag to all resources within the Resource Group: tamops-tagging

$ResourceGroup = Get-AzureRMResourceGroup -name "tamops-tagging"
$TagName = "environment"
$TagValue = "prd"

Set-AzureRMResourceGroup -Name $ResourceGroup.ResourceGroupName -Tag @{ $TagName="$TagValue" }

foreach ($Resource in $ResourceGroup){

Get-AzureRmResource -ResourceGroupName $Resource.ResourceGroupName | ForEach-Object {Set-AzureRmResource -ResourceId $_.ResourceId -Tag $Resource.Tags -Force }


Example of Resource Tagging output:

View Resources that are Tagged with environment = prd

In Azure Portal

Select All Resources and edit drop-down as below under “Filter Tags”

Azure PowerShell

$TagName = "environment"
$TagValue = "prd"

(Get-AzureRMResource -Tag @{ $TagName="$TagValue"})

Sample output:

Having discussed how to apply Resource Tags using both Azure Portal and Azure PowerShell – I recommend creating AzureRM Templates with Resource Tagging in mind, inside each Azure Resource within your Azure Azure RM Template add:

"tags": {
        "CostCenter": "{\"environment\":\"prd\"}"

Thanks for reading, I think adding Resource Tags will have a serious benefit to your subscription from a billing and organisational benefit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s