Open In App

Microsoft Azure – Get Azure Subscription Details Using Resource Graph Query

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.

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:

 

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:

 

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:

 

Article Tags :