0

I'm trying to create a Workbook Parameter drop down, where we can choose Subscription to filter.
However, 1 Tenant/ Directory might have one or more subscriptions.
Instead of a flat subscription drop-down list like this:,

  • Subscription-1
  • Subscription-2
  • Subscription-3
  • Subscription-4
  • Subscription-5

Is there a way to create a drop-down list of subscription grouped by Tenant/Directory similar to the ones in Azure Resource Graph Explorer page (located in the right side) like this:?

Tenant 1

  • Subscription-1
  • Subscription-2

Tenant 2

  • Subscription 3

Tenant 3

  • Subscription 4
  • Subscription-5

Thank you very much for your help.

sourab maity
  • 1,025
  • 2
  • 8
  • 16
Jaysec
  • 27
  • 5

2 Answers2

0

A partial solution:

  1. create a new parameter
  2. pick "subscription picker" as the parameter type
  3. pick "query" as the "get data from" option
  4. in the query, set the data source to "Azure Resource Graph"
  5. pick all or default (subscription filtered subs) as the subscriptions value
  6. use the query
ResourceContainers | where type =~ "microsoft.resources/subscriptions"
// add any other filters you want here
| project id, name, group=tenantId

you'll get a dropdown parameter that is subs grouped by tenant.

limitation: Azure Resource Graph doesn't have tenant names (not sure why), so the dropdown itself won't have those. you'd possibly have to query ARM separately to get all the tenants by name+id and merge with that if you want tenant names?

Update: Jason went the extra step of using merge to get data, which i'm not sure why i didn't think of that.

you could possibly use the ARM data source and query the /tenants api to get that info to use in the merge: enter image description here

in my place i'm only getting on tenant back in that list, though, so i can't verify that it will work and get you all the tenants. i swear i have access to more than one but i'm only getting back my primary one?

John Gardner
  • 24,225
  • 5
  • 58
  • 76
  • 1
    Hi John, cheers to that. group=tenantId is exactly the command I was looking for to achieve that results. – Jaysec Jan 18 '21 at 01:19
  • Yes, I've been tinkering with using external blob storage to store the TenantID/Name definition, however resource graph couldn't refer to external source. – Jaysec Jan 18 '21 at 02:17
0

On top of John Gardner's answers, I managed to get it work by creating a Merge between 2 queries. one for the resource graph, and one on KQL referring to external Blob storage with mapping between TenantId and Tenant Name. Create the parameter, use Merge, and select the Tenant Name field, rename it as "group".

Jaysec
  • 27
  • 5
  • if ARM has a call that will return tenant id and name, instead of merge of that kql blob part, you could do a merge between the arm call using the ARM data source? – John Gardner Jan 29 '21 at 01:44