Tagging a VM using a template

Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Flexible scale sets ✔️ Uniform scale sets

This article describes how to tag a VM in Azure using a Resource Manager template. Tags are user-defined key/value pairs which can be placed directly on a resource or a resource group. Azure currently supports up to 50 tags per resource and resource group. Tags may be placed on a resource at the time of creation or added to an existing resource.

This template places tags on the following resources: Compute (Virtual Machine), Storage (Storage Account), and Network (Public IP Address, Virtual Network, and Network Interface). This template is for a Windows VM but can be adapted for Linux VMs.

Click the Deploy to Azure button from the template link. This will navigate to the Azure portal where you can deploy this template.

Simple deployment with Tags

This template includes the following tags: Department, Application, and Created By. You can add/edit these tags directly in the template if you would like different tag names.

Azure tags in a template

As you can see, the tags are defined as key/value pairs, separated by a colon (:). The tags must be defined in this format:

"tags": {
    "Key1" : "Value1",
    "Key2" : "Value2"
}

Save the template file after you finish editing it with the tags of your choice.

Next, in the Edit Parameters section, you can fill out the values for your tags.

Edit Tags in Azure portal

Click Create to deploy this template with your tag values.

Next steps