We all heard a lot about Tags and this something is actually makes your job very easy specially at the enterprise level where there are lots of different teams and departments. In this post we would be assigning Tags to the existing VM with the help of Powershell.
These Tags gives metadata to Azure resources to logically organize them into a Taxonomy. Each Tag consist of Name and Value pair. After you apply tags , you can retrieve all the resources in your subscription with that Tag name.
Tag enables you to retrieve related resources from different resource groups. This approach is very helpful when you need to organize resources for billing or management.
Few Limitations
In this scenario we have on VM as shown and no Tags applied and we would be applying tags to this resource with the help of PS.
Once you see its succeeded , you can refresh the resource and tag would appear as shown -
These Tags gives metadata to Azure resources to logically organize them into a Taxonomy. Each Tag consist of Name and Value pair. After you apply tags , you can retrieve all the resources in your subscription with that Tag name.
Tag enables you to retrieve related resources from different resource groups. This approach is very helpful when you need to organize resources for billing or management.
Few Limitations
- Not all resource type support Tags.
- Each resource or resource group can have max. of 50 Tags
- Tags applied to resource group are not inherited.
- Tag cant be applied to classic resources.
- User must have write access to apply tags on that resource
In this scenario we have on VM as shown and no Tags applied and we would be applying tags to this resource with the help of PS.
Get-AzResource This can help you get the resources and you can choose the name or resource that you are looking for in my case its resource group
$r = Get-AzResource -ResourceName "lab-vm"
-ResourceGroupName "ARG"
We are getting the resource info in a variable so that we can run the set command next easily
Set-AzureRmResource -Tag @{ Dept="IT";
Environment="Test" } -ResourceId $r.ResourceId -Force
In this command we are setting the Tags as array and we can give multiple values as array or by separating with semi colan ;
You will see the result as shown:
thanks !!
ReplyDeleteIm thankful for the article post.Thanks Again. Fantastic.
ReplyDeletejava online training hyderabad
core java online training hyderabad