Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Resource Manager - update tags of existing resource group

Is it possible to update tags of existing resource group, using Azure Resource Manager template? Cause, each time i do a deployment to Azure via Azure Resource Manager - my tags on Azure Resource Group are being removed :(

like image 720
Антон Курьян Avatar asked Nov 28 '25 01:11

Антон Курьян


1 Answers

I think the PowerShell implementation of tags on resources and groups is not implemented the way you would expect, which makes this a challenge at the moment. I don't know of a way append a tag without some gymnastics in deconstructing the hashtable.

Whenever you set tags in PowerShell it's a "replace" and not an append. So you could get, then append to the hashtable and put it back but I haven't found a good way to do that. See https://github.com/Azure/azure-powershell/issues/726

If you just want to replace tags on a resource group, rather than using New-AzureResourceGroup (I'm assuming that's what you're using due to the behavior I'm seeing) use:

    Set-AzureResourceGroup -Name GroupName -Tag @{Name='TagName';Value='TagValue'} #this will replace all the tags with this one
    New-AzureResourceGroupDeployment -ResourceGroupName GroupName ...

When you use New-AzureResourceGroup, if you want to update tags you'd have to create a hash table with the existing and new tags.

like image 52
bmoore-msft Avatar answered Nov 29 '25 17:11

bmoore-msft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!