Open In App

How to List all Tags and their Values in Azure?

Last Updated : 30 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: Azure Tags

Here in this article, we will show you how to find the list of tags names and their assigned values in azure in a simple easy step in azure without using any third-party service. To find tags and their values we will be using the azure customized KQL resource graph query to find and export data from Azure Portal itself. Let’s find out how we can do that.

Pre-requisites: One should have at least a Role Based Reader Access role to run and view the results in Azure.

Implementation

Follow the steps to list out all the azure resource tags and their values using the KQL resource graph query.

Step 1: Log in to Azure Portal

Step 2: Access the Resource Graph Explorer from Azure Global Search.

Resource Graph Explorer

 

Step 3: Once you open the Resource Graph Explorer >> Select the scope of your choice and add the following KQL resource graph query in the query section >> click on Run query. Refer to the image below.

Note: Scope you can choose either Directory, Management Group, or a Subscription of your choice.

ResourceContainers
| where isnotempty(tags)
| project tags
| mvexpand tags
| extend tagKey = tostring(bag_keys(tags)[0])
| extend tagValue = tostring(tags[tagKey])
| union (
    resources
    | where isnotempty(tags)
    | project tags
    | mvexpand tags
    | extend tagKey = tostring(bag_keys(tags)[0])
    | extend tagValue = tostring(tags[tagKey])
)
| distinct tagKey, tagValue
| where tagKey !startswith "hidden-"
Run query

 

Sample Output: 

The above query returns the list of all the tag names and their assigned values at the selected scope and also the count of results.

list of all the tag names

 

That’s all. This is how you can find the list of all azure resource-assigned tags and their values.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads