Adventures with PowerShell: Add or Update Resource Tags

Whenever I deploy a release to Azure, using Azure DevOps, I like to add or update a tag with the current build version.

To do this, I created a PowerShell script called UpdateTags.ps1.

In full disclosure, transparency, and whatever other buzz words there are now for coming clean, I cobbled this script together from a variety of online resources.

It takes three parameters:

  • -ResourceGroupName The name of the resource group.
  • -ResourceName The name of the resource, in my example, the name of the application service.
  • -Tags A hashtable of the tags to be added or updated.

To execute the script locally, run .\UpdateTags.ps1 -ResourceGroupName RESOURCE_GROUP_NAME -ResourceName RESOURCE_NAME -Tags @{ Tag1= "Value1", Tag2="Value2", Tag3="Value3" }.

That’s it!

Is there a better way? Is there a built in way? If so, please share!


Discover more from Matt Ruma

Subscribe to get the latest posts sent to your email.

Leave a Reply

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