Daniel's Tech Blog

Cloud Computing, Cloud Native & Kubernetes

Referring to resource group tags in your Azure Resource Manager templates

Just a short blog post for a small useful hint.

Assuming you are familiar with the Azure Resource Manager tags, I want to show you how you can refer to the resource group tags in your templates. That said, you only define the tags at the resource group level and you want to use them for every resource that is going to be deployed in this specific resource group.

First you have to define the tags during or after the resource group deployment. Then you can refer to the tags in your ARM template by using the resourceGroup() function. For example, you are using tags like department and environment with different values. Then you only have to add the following lines to the specific resources in your template.

"tags": {
    "department": "[resourceGroup().tags.department]",
    "environment": "[resourceGroup().tags.environment]"
},

Tags01

It would be better to have an inheritance option here , but using the resourceGroup() function is an easy way to use the defined tags from the resource group.

WordPress Cookie Notice by Real Cookie Banner