How to get all Azure Resources without tags in a Azure Resource Group

DevX picture DevX · Sep 14, 2017 · Viewed 8.6k times · Source

In my Azure dev/test lab (DTL), there are many resources which were not tagged. How can I get a list of all untagged resources under DTL/resource group?

Answer

huysmania picture huysmania · Sep 15, 2017

Here's a simple PowerShell loop to get untagged resources.

$resources = Get-AzureRmResource
foreach($resource in $resources)
{
    if ($resource.Tags -eq $null)
    {
        echo $resource.Name, $resource.ResourceType
    }
}

Other ways to query this information and also set tags programmatically or as part of resource deployments are described here.

If you want to avoid the situation of ending up with untagged resources, you could enforce a customized policy that all resources should have a value for a particular tag.