Search code examples
azureazure-virtual-machineazure-data-explorerkql

How to list all the tags for VM's in Azure?


I want to list all the tags tied to select VM's (or all if that is easier) in Azure. While the az cli is one option (it works fine), since I have so many of them is there a kql query for this I can use ?


Solution

  • You can use this to list all tags related to a VM.

    AzureActivity
    | where ResourceProviderValue == "Microsoft.Compute/virtualMachines"
    | where ResourceId contains "<VM Resource ID>"
    | extend tags = tostring(Properties.Tags)
    | project tags
    

    You can also remove the where statement about VM Resource ID to display all tags connected to any VM.