July 6, 2018

How to update specified tag from a resource

The usage of Tags on Azure resources is a very common and very useful for several reasons that I will not cover on this post. Although in some occasions, if you need to update a Tag from a resource, because either it’s not suitable anymore or you are reaching the limit of the number of Tags allowed by Azure.

In this case the idea is reuse the Tag Shutdown, although with different values for a specific virtual machine

#Get all tags from Resource (VM)

$tags = (Get-AzureRMVM -ResourceName $VMName -ResourceGroupName $ResourceGroup).Tags

#Since this is a hash table, not an array. Update the value for Shutdown.

$tags[‘Shutdown’] = “NewValue”

#Write the hash table back to the resource

$UpdateTag = Set-AzureRmResource -Tag $tags -ResourceName $ServerName -ResourceGroupName $ResourceGroup -ResourceType Microsoft.Compute/virtualMachines

Cheers,

Marcos Nogueira
Azure MVP
azurecentric.com
Twitter: @mdnoga

Written by Marcos Nogueira

Marcos Nogueira

With more than 18 years experience in Datacenter Architectures, Marcos Nogueira is currently working as a Principal Cloud Solution Architect. He is an expert in Private and Hybrid Cloud, with a focus on Microsoft Azure, Virtualization and System Center. He has worked in several industries, including Aerospace, Transportation, Energy, Manufacturing, Financial Services, Government, Health Care, Telecoms, IT Services, and Gas & Oil in different countries and continents. Marcos was a Canadian MVP in System Center Cloud & Datacenter Managenment and he has +14 years as Microsoft Certified, with more than 100+ certifications (MCT, MCSE, and MCITP, among others). Marcos is also certified in VMware, CompTIA and ITIL v3. He assisted Microsoft in the development of workshops and special events on Private & Hybrid Cloud, Azure, System Center, Windows Server, Hyper-V and as a speaker at several Microsoft TechEd/Ignite and communities events around the world.

Share

Marcos Nogueira

With more than 18 years experience in Datacenter Architectures, Marcos Nogueira is currently working as a Principal Cloud Solution Architect. He is an expert in Private and Hybrid Cloud, with a focus on Microsoft Azure, Virtualization and System Center. He has worked in several industries, including Aerospace, Transportation, Energy, Manufacturing, Financial Services, Government, Health Care, Telecoms, IT Services, and Gas & Oil in different countries and continents. Marcos was a Canadian MVP in System Center Cloud & Datacenter Managenment and he has +14 years as Microsoft Certified, with more than 100+ certifications (MCT, MCSE, and MCITP, among others). Marcos is also certified in VMware, CompTIA and ITIL v3. He assisted Microsoft in the development of workshops and special events on Private & Hybrid Cloud, Azure, System Center, Windows Server, Hyper-V and as a speaker at several Microsoft TechEd/Ignite and communities events around the world.

You may also like...

1 Response

  1. February 6, 2019

    […] that you need to intervene and either remove some of the tags or reuse them. On my previous post (How to update specified tag from a resource) I showed a way to update a specific tag in a Azure Resource. Some time that will be enough, other […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: