Skip to content
Related Articles
Open in App
Not now

Related Articles

Microsoft Azure – Get Azure Subscription Details Using Resource Graph Query

Improve Article
Save Article
  • Last Updated : 13 Dec, 2022
Improve Article
Save Article

In this article, you will learn about how you can get the azure subscriptions’ complete JSON information by running the following KQL Queries in Azure Resource Graph Explorer in Azure Portal. Let’s get started by checking out the different queries with examples.

Syntax:

ResourceContainers
| where type =~ 'microsoft.resources/subscriptions'

the following data can be achieved using the above KQL Query.

  • Tenant Id
  • Subscription Id
  • Subscription Name
  • Subscription Properties

Example 1: Use the below following Azure Resource Graph Query to get all the Azure Subscriptions under the Management Group with Subscription Name and Subscription ID.

ResourceContainers
| where type =~ 'microsoft.resources/subscriptions'
| project SubscriptionName=name, subscriptionId

this query returns the list of Subscription Name and their Subscription ID. 

Note: You can also export the list by clicking
on Download as CSV. (Refer Output Image)

Output:

query

 

Example 2: Use the below query to get the list of Subscription Name, Subscription Id, and Tenant Id.

ResourceContainers
| where type =~ 'microsoft.resources/subscriptions'
| project SubscriptionName=name, subscriptionId, tenantId

Output:

query

 

Example 3: Use the following query to get the list of Subscription Names and their properties.

ResourceContainers
| where type =~ 'microsoft.resources/subscriptions'
| project SubscriptionName=name, properties

Output:

output

 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!