After a first insight into Azure Resource Graph (in public preview as of Oct 2018) here, lets do a bit of an analysis of the data, the Az.ResourceGraph Module provides.
Lets say, we want to know which kind of resources (providers) we have in our subscription
The search query for this is simple: „project type“
1 2 |
$q = 'project type' Search-AzGraph -Query $q |
This query is returning a list of provider types
1 2 3 4 5 6 7 8 |
type ---- microsoft.network/networkinterfaces microsoft.compute/virtualmachines/extensions microsoft.storage/storageaccounts microsoft.operationsmanagement/solutions microsoft.compute/virtualmachines/extensions microsoft.network/virtualnetworks |
Now we want to see only unique records, nothing easier that thet with the PowerShell Select-Object -Unique parameter switch.
1 |
Search-AzGraph -Query $q |Select-Object -unique |
which emits just a single line 🙁
1 2 3 |
type ---- microsoft.automation/automationaccounts/runbooks |
What we learned is that Azure Resource Graph emits a PSObject, but the content is within a „NoteProperty“. To see what we want – a list of the resource types in Azures – we need to use -expandproperty first and then use the -unique.
So our one-liner would be
1 2 |
$q = 'project type' Search-AzGraph -Query $q |Select-Object -ExpandProperty type|Select-Object -Unique|Sort-Object |
… which gets us a nice type list of our Resources.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
microsoft.automation/automationaccounts microsoft.automation/automationaccounts/runbooks microsoft.compute/availabilitysets microsoft.compute/disks microsoft.compute/virtualmachines microsoft.compute/virtualmachines/extensions microsoft.devices/iothubs microsoft.devtestlab/labs microsoft.devtestlab/labs/virtualmachines microsoft.devtestlab/schedules microsoft.insights/autoscalesettings microsoft.insights/metricalerts microsoft.insights/scheduledqueryrules microsoft.keyvault/vaults microsoft.labservices/labaccounts microsoft.logic/workflows microsoft.network/loadbalancers microsoft.network/networkinterfaces microsoft.network/networksecuritygroups microsoft.network/publicipaddresses microsoft.network/virtualnetworks microsoft.operationalinsights/workspaces microsoft.operationsmanagement/solutions microsoft.recoveryservices/vaults microsoft.solutions/applicationdefinitions microsoft.storage/storageaccounts microsoft.web/connections microsoft.web/customapis |
More to come on ARG soon…