Being an architect another job is to define tagging policy if its not there in place . And it’s very simple work to decide what is the best possible way to tag resources if have gone through my last tagging post . Now let’s talk about how to deploy tagging in azure .
If you want to overwrite tag on Resource group then follow this script :
"Remember this script will overwrite your exciting tagging "
$ResourceGroupName = "Type Your RG Name"
#it will show your existing Tagging with RG details
Get-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName
#it will show your existing Tagging
(Get-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName).Tags
#new Tag
$tags = @{"tag-Global"="All"; "testtag-Program"="IBM"; "Created-By"="Subhendu" }
#Apply
Set-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName -Tag $tags
If you dont want to overwite your exsting tagging , just want to add new tag . Follow the bellow one .
"Remember this script will add this new tags with your exciting tagging "
$ResourceGroupName = "Type Your RG Name"
Get-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName
$tags = (Get-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName).Tags
$tags += @{"Testtag-Global"="All"; "Testtag-Program"=""; "Created-By"="Subhendu" }
Set-AzureRmResourceGroup -ResourceGroupName $ResourceGroupName -Tag $tags
if you want to tag your VM only follw this script :
"Remember this script will overwrite your exciting tagging " #Type VM Name $VMName = "Type your VM here" #To show existing Tag (Get-AzureRmResource -ResourceName $VMName).Tags #To store VM RG details in value $RGName = (Get-AzureRmResource -ResourceName $VMName).ResourceGroupName #Tag you want to apply $tags = @{"tag-Global"="All"; "testtag-Program"="IBM"; "Created-By"="Subhendu" } Set-AzureRMResource -ResourceGroupName $RGName -Name $VMName -ResourceType "Microsoft.Compute/VirtualMachines" -Tag $tags -Force #it will show you Final Tagging (Get-AzureRmResource -ResourceName $VMName).Tags
Creating NSG in azure is easy unless you want to create multiple NSG with multiple…
# Mention your VM here $VMName = "SubhenduTestVM" # Mention your Stage Storage here $stagestorageaccountname…
Hope you are doing great . Current Time is very critical for us . I…
Being a part of Microsoft Education I have explored powershell long time back . But…
Sorry !! But Yes . Microsoft is about to release new exam in Azure Segment…
Migration is always a part of our life and part of this fantastic IT world…