{"id":13112,"date":"2020-07-23T11:02:03","date_gmt":"2020-07-23T11:02:03","guid":{"rendered":"https:\/\/www.testpreptraining.com\/tutorial\/?page_id=13112"},"modified":"2020-08-28T04:34:19","modified_gmt":"2020-08-28T04:34:19","slug":"apply-tags-to-organize-your-azure-resources","status":"publish","type":"page","link":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/","title":{"rendered":"Apply Tags to organize your Azure Resources"},"content":{"rendered":"\n<p class=\"has-text-align-right\"><strong><a href=\"https:\/\/www.testpreptraining.ai\/tutorial\/exam-az-104-microsoft-azure-administrator-associate\/\">Return to AZ-104 Tutorial<\/a><\/strong><\/p>\n\n\n\n<p>We can apply tags to our Azure resources, resource groups, and subscriptions and logically organize them into a taxonomy. Each tag consists of a name and a value pair. Note, tag names are case-insensitive for operations. Any tag with a tag name, irrespective of the casing, is updated or retrieved. But, the resource provider may keep the casing you provide for the tag name.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Required access to Apply Tag<\/strong><\/h4>\n\n\n\n<p>In order to apply tags to a resource, we must have write access to the Microsoft.Resources\/tags resource type. In which case the Tag Contributor role assists in applying tags to an entity without having access to the entity itself. At present, the tag contributor role cannot apply tags to resources or resource groups through the portal. It can apply tags to subscriptions through the portal. Also, it supports all tag operations through PowerShell and REST API.<\/p>\n\n\n\n<p><strong>Note &#8211; <\/strong>Contributor role allows the required access to apply tags to any entity. In order to apply tags to only one resource type, we suggest to use the contributor role for that resource. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps to Apply Tags using PowerShell<\/strong><\/h3>\n\n\n\n<p>The Azure PowerShell has two commands for applying tags namely &#8211; New-AzTag and Update-AzTag. In which case you must have the Az.Resources module 1.12.0 or later. We can check the version with Get-Module Az.Resources. <\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>New-AzTag replaces<\/strong><\/h5>\n\n\n\n<p>The New-AzTag is used to replace all tags on the resource, resource group, or subscription. When calling the command, pass in the resource ID of the entity that we wish to tag.<\/p>\n\n\n\n<p><strong>Example &#8211; <\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;Dept&#8221;=&#8221;Finance&#8221;; &#8220;Status&#8221;=&#8221;Normal&#8221;}<br>$resource = Get-AzResource -Name demoStorage -ResourceGroup demoGroup<br>New-AzTag -ResourceId $resource.id -Tag $tags<\/p>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p>Properties :<br>Name Value<br>====== =======<br>Dept Finance<br>Status Normal<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Update-AzTag<\/strong><\/h5>\n\n\n\n<p>We use Update-AzTag to add tags to a resource that already has tags. For this we set the -Operation parameter to Merge. <\/p>\n\n\n\n<p><strong>Example &#8211; <\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;Dept&#8221;=&#8221;Finance&#8221;; &#8220;Status&#8221;=&#8221;Normal&#8221;}<br>Update-AzTag -ResourceId $resource.id -Tag $tags -Operation Merge<\/p>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p>Properties :<br>Name Value<br>=========== ==========<br>Status Normal<br>Dept Finance<br>Team Compliance<br>Environment Production<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/www.testpreptraining.ai\/microsoft-azure-administrator-associate-az-104-free-practice-test\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.png\" alt=\"Practice Test for AZ-104\"\/><\/a><\/figure><\/div>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Types of Tags<\/strong><\/h5>\n\n\n\n<p>We will now use example to illustrate the uses of various tags <\/p>\n\n\n\n<p><strong>Replace Tag<\/strong><\/p>\n\n\n\n<p>Set the -Operation parameter to Replace, the existing tags are replaced by the new set of tags.<\/p>\n\n\n\n<p>$tags = @{&#8220;Project&#8221;=&#8221;ECommerce&#8221;; &#8220;CostCenter&#8221;=&#8221;00123&#8221;; &#8220;Team&#8221;=&#8221;Web&#8221;}<br>Update-AzTag -ResourceId $resource.id -Tag $tags -Operation Replace<\/p>\n\n\n\n<p><strong>Add a New Tag<\/strong> <strong>to a resource group<\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;Dept&#8221;=&#8221;Finance&#8221;; &#8220;Status&#8221;=&#8221;Normal&#8221;}<br>$resourceGroup = Get-AzResourceGroup -Name demoGroup<br>New-AzTag -ResourceId $resourceGroup.ResourceId -tag $tags<\/p>\n\n\n\n<p><strong>Update Tags<\/strong> <strong>for a resource group<\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;CostCenter&#8221;=&#8221;00123&#8221;; &#8220;Environment&#8221;=&#8221;Production&#8221;}<br>$resourceGroup = Get-AzResourceGroup -Name demoGroup<br>Update-AzTag -ResourceId $resourceGroup.ResourceId -Tag $tags -Operation Merge<\/p>\n\n\n\n<p><strong>Add a new set of tags to a subscription<\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;CostCenter&#8221;=&#8221;00123&#8221;; &#8220;Environment&#8221;=&#8221;Dev&#8221;}<br>$subscription = (Get-AzSubscription -SubscriptionName &#8220;Example Subscription&#8221;).Id<br>New-AzTag -ResourceId &#8220;\/subscriptions\/$subscription&#8221; -Tag $tags<\/p>\n\n\n\n<p><strong>Update the tags for a subscription<\/strong><\/p>\n\n\n\n<p>$tags = @{&#8220;Team&#8221;=&#8221;Web Apps&#8221;}<br>$subscription = (Get-AzSubscription -SubscriptionName &#8220;Example Subscription&#8221;).Id<br>Update-AzTag -ResourceId &#8220;\/subscriptions\/$subscription&#8221; -Tag $tags -Operation Merge<\/p>\n\n\n\n<p><strong>List tags<\/strong><\/p>\n\n\n\n<p>In order to get the tags for a resource, resource group, or subscription, use the <strong>Get-AzTag command <\/strong>and pass in the resource ID for the entity.<\/p>\n\n\n\n<p><strong>Remove tags<\/strong><\/p>\n\n\n\n<p>In order to remove specific tags, use Update-AzTag and set -Operation to Delete. Pass in the tags you want to delete.<\/p>\n\n\n\n<p>$removeTags = @{&#8220;Project&#8221;=&#8221;ECommerce&#8221;; &#8220;Team&#8221;=&#8221;Web&#8221;}<br>Update-AzTag -ResourceId $resource.id -Tag $removeTags -Operation Delete<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps to Apply Tags using Azure CLI<\/strong><\/h3>\n\n\n\n<p>When adding tags to a resource group or resource, you can either overwrite the existing tags or append new tags to existing tags.<\/p>\n\n\n\n<p><strong>Overwrite the tags on a resource<\/strong><\/p>\n\n\n\n<p>az resource tag &#8211;tags &#8216;Dept=IT&#8217; &#8216;Environment=Test&#8217; -g examplegroup -n examplevnet &#8211;resource-type &#8220;Microsoft.Network\/virtualNetworks&#8221;<\/p>\n\n\n\n<p><strong>Append a tag to the existing tags on a resource<\/strong><\/p>\n\n\n\n<p>az resource update &#8211;set tags.&#8217;Status&#8217;=&#8217;Approved&#8217; -g examplegroup -n examplevnet &#8211;resource-type &#8220;Microsoft.Network\/virtualNetworks&#8221;<\/p>\n\n\n\n<p><strong>Overwrite the existing tags on a resource group<\/strong><\/p>\n\n\n\n<p>az group update -n examplegroup &#8211;tags &#8216;Environment=Test&#8217; &#8216;Dept=IT&#8217;<\/p>\n\n\n\n<p><strong>Append a tag to the existing tags on a resource group<\/strong><\/p>\n\n\n\n<p>az group update -n examplegroup &#8211;set tags.&#8217;Status&#8217;=&#8217;Approved&#8217;<\/p>\n\n\n\n<p>At present, Azure CLI doesn&#8217;t have a command for applying tags to subscriptions. But, we can use CLI to deploy an ARM template that applies the tags to a subscription.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Steps to Apply Tags using Portal<\/strong><\/h3>\n\n\n\n<p>In case a user does not have the required access for applying tags, we can assign the Tag Contributor role to the user.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/azure\/includes\/media\/resource-manager-tag-resources\/view-tags.png\" alt=\"Applying Tags for resource or resource group\"\/><\/figure><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li>To view the tags for a resource or a resource group, look for existing tags in the overview. If you have not previously applied tags, the list is empty.<\/li><li>To add a tag, select Click here to add tags.<\/li><li>Provide a name and value.<\/li><li>Continue adding tags as needed. When done, select Save.<\/li><li>The tags are now displayed in the overview.<\/li><li>To add or delete a tag, select change.<\/li><li>To delete a tag, select the trash icon. Then, select Save.<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Tags Bulk Assignment  to Multiple Resources<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>From any list of resources, select the checkbox for the resources you want to assign the tag. Then, select Assign tags.<\/li><li>Add names and values. When done, select Save.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.testpreptraining.ai\/microsoft-azure-administrator-associate-az-104-online-course\"><img decoding=\"async\" src=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/07\/testpreptraining.ai-2-1-750x117.png\" alt=\"\" class=\"wp-image-12856\"\/><\/a><\/figure><\/div>\n\n\n\n<p class=\"has-text-align-right\"><strong>Reference: <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/management\/tag-resources\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Documentation<\/a><\/strong><\/p>\n\n\n\n<p><strong><a href=\"https:\/\/www.testpreptraining.ai\/tutorial\/exam-az-104-microsoft-azure-administrator-associate\/\">Return to AZ-104 Tutorial<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Return to AZ-104 Tutorial We can apply tags to our Azure resources, resource groups, and subscriptions and logically organize them into a taxonomy. Each tag consists of a name and a value pair. Note, tag names are case-insensitive for operations. Any tag with a tag name, irrespective of the casing, is updated or retrieved. But,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-13112","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apply Tags to organize your Azure Resources - Testprep Training Tutorials<\/title>\n<meta name=\"description\" content=\"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apply Tags to organize your Azure Resources - Testprep Training Tutorials\" \/>\n<meta property=\"og:description\" content=\"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/\" \/>\n<meta property=\"og:site_name\" content=\"Testprep Training Tutorials\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-28T04:34:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/\",\"name\":\"Apply Tags to organize your Azure Resources - Testprep Training Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\"},\"datePublished\":\"2020-07-23T11:02:03+00:00\",\"dateModified\":\"2020-08-28T04:34:19+00:00\",\"description\":\"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apply Tags to organize your Azure Resources\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#website\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"name\":\"Testprep Training Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#organization\",\"name\":\"Testprep Training\",\"url\":\"https:\/\/www.testpreptraining.ai\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"contentUrl\":\"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png\",\"width\":583,\"height\":153,\"caption\":\"Testprep Training\"},\"image\":{\"@id\":\"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apply Tags to organize your Azure Resources - Testprep Training Tutorials","description":"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/","og_locale":"en_US","og_type":"article","og_title":"Apply Tags to organize your Azure Resources - Testprep Training Tutorials","og_description":"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!","og_url":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/","og_site_name":"Testprep Training Tutorials","article_modified_time":"2020-08-28T04:34:19+00:00","og_image":[{"url":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-content\/uploads\/2020\/06\/practice-test-2.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/","url":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/","name":"Apply Tags to organize your Azure Resources - Testprep Training Tutorials","isPartOf":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website"},"datePublished":"2020-07-23T11:02:03+00:00","dateModified":"2020-08-28T04:34:19+00:00","description":"Learn to apply tags to organize your Azure Resources with expert online tutorials and practice exam. Start preparing for Microsoft AZ-104 Exam Now!","breadcrumb":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/apply-tags-to-organize-your-azure-resources\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.testpreptraining.ai\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Apply Tags to organize your Azure Resources"}]},{"@type":"WebSite","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#website","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","name":"Testprep Training Tutorials","description":"","publisher":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.testpreptraining.ai\/tutorial\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#organization","name":"Testprep Training","url":"https:\/\/www.testpreptraining.ai\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","contentUrl":"https:\/\/www.testpreptraining.com\/tutorial\/wp-content\/uploads\/2020\/07\/tpt-logo-6.png","width":583,"height":153,"caption":"Testprep Training"},"image":{"@id":"https:\/\/www.testpreptraining.ai\/tutorial\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/13112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/comments?post=13112"}],"version-history":[{"count":5,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/13112\/revisions"}],"predecessor-version":[{"id":18363,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/pages\/13112\/revisions\/18363"}],"wp:attachment":[{"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/media?parent=13112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/categories?post=13112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testpreptraining.ai\/tutorial\/wp-json\/wp\/v2\/tags?post=13112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}