How to apply a tag to the azure resource group using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

Like Azure VM, we can apply the azure tags to the resource group or any other resources. The tagging works on the resource ID and in azure, all the resources come with the resource ID property.

To apply the tag to the azure resource group, we first need to use get the resource group details to use its resource ID. The below code shows that how we can apply the new tag to the azure resource group.


PS C:\> $rg = Get-AzResourceGroup -Name AnsibleTestRG
PS C:\> $tag = @{Owner='Chirag'; CostCenter='USFinance'}
PS C:\> New-AZTag -ResourceId $rg.ResourceId -Tag $tag -Verbose


Published on 06-Apr-2021 11:24:07