Last active
June 10, 2020 15:45
-
-
Save ppanyukov/10e72ea409f80c661c7604034bb37983 to your computer and use it in GitHub Desktop.
Azure Graph: List all tags as name value columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem: tags in Azure are an objects like this: | |
// {tag_name: tag_value, tag_name2: tag_value2} | |
// | |
// What we want is to list these as table with name,value columns. | |
// The way I found is to convert the tag objects into arrays by | |
// simple text replace and then we can tag and value by index and | |
// can project them as columns. :) | |
Resources | |
| project tags | |
| extend tags = tostring(tags) | |
| extend tags = replace(",", "],[", tags) | |
| extend tags = replace("{", "[[", tags) | |
| extend tags = replace("}", "]]", tags) | |
| extend tags = replace(":", ",", tags) | |
| extend tags = todynamic(tags) | |
| mvexpand tags | |
| project name = tags[0], value = tags[1] | |
| where notnull(name) | |
| where name !hasprefix "hidden" | |
| summarize count() by tostring(name), tostring(value) | |
| order by name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment