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


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.

Example

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

Output

Updated on: 06-Apr-2021

534 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements