Forum Discussion

NotSoNewOzzie's avatar
Sep 30, 2024

Azure Resource Graph query to get subscription properties

I am very new to ARG queries. I am struggling to figure out how to get a list of our Azure Subscriptions using ARG, including some of the properties you see on the properties pane when using the azure portal. In particular, I want the property visually labelled "ACCOUNT ADMIN".
Can anyone point me in the right direction?

 

resourcecontainers
where type == 'microsoft.resources/subscriptions'
project subscriptionId, name, owner = ???
  • NotSoNewOzzie you're almost there. You're querying the right table, but you would need to dive into the attributes of interest differently. First, don't use "project" but rather use "extend" - which adds a column with the data you want. For example, I want one of the management groups a subscription falls under (not super helpful on it's own I know):

    resourcecontainers
    where type == "microsoft.resources/subscriptions"
    extend properties.managementGroupAncestorsChain[0].name
     
    In your case, I'm assuming you're looking for a specific tag associated with a subscription:
    resourcecontainers
    where type == "microsoft.resources/subscriptions"
    where tags.Owner == "ACCOUNT ADMIN"
     
    Hope this helps!

Resources