Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Microsoft Azure- Writing Queries and Creating Dashboards using Azure Resource Graph

  • Last Updated : 09 Nov, 2021

In this article, we are going to write an azure resource graph queries in azure workbooks and then we will pin it to Azure Dashboards.

Implementation:

Follow the below steps to implement the above problem statement:

Step 1: Login into the Azure Portal.

Step 2: Go to Azure Monitor Service or You can search for the monitor in Search Bar.

Step 3: From the Left-Menu Click on Workbooks.

Step 4: Then Click on + New.

Step 5: Click on + Add

Step 6: Click on Add query

Step 7: In Edit Query item >> Select Data Source, then Select Azure Resource Graph.



Step 8: Then, Select the Scope (Either Single Resource or Subscription or Subscriptions according to your needs)

Step 9: then Select Visualization, this is Optional. By default, it will select Table.

Step 10: then Select Size, this is Optional.  By default, it will select Medium. You can always choose your recommended size.

Step 11: Leave Color palatte as auto (this is Advanced for adding colors to Visualization

Step 12: Now Add your Resource Graph Query, then click on Run the Query

Example: 

Azure Resource Graph Query to find the total number of orphaned disks by Subscription.

Resources | where type has “microsoft.compute/disks” | extend diskState = tostring(properties.diskState) | where  diskState == ‘Unattached’ //or managedBy == “” | project DiskName=name, diskState, Owner=managedBy, SubscriptionName, ResourceGroup=resourceGroup, Location=location, Tags=tags | summarize count() by SubscriptionName

Azure Resource Graph Query to find orphaned disks.



Resources | where type has “microsoft.compute/disks” | extend diskState = tostring(properties.diskState) | where  diskState == ‘Unattached’ //or managedBy == “” | project DiskName=name, diskState, Owner=managedBy, SubscriptionName, ResourceGroup=resourceGroup, Location=location, Tags=tags

Step 13: Click on Advanced Settings in the Edit Query item

Step 14: Check the following options Always show the pin icon on this step, Show refresh icon when not editing, Show Export to Excel button when not editing.

Provide the Chart Title and Click on Done Editing:

Step 15: Click on Done Editing, then Click on Save to save the Changes.

Step 16: On the right top corner you will get an option to pin to Azure Dashboard. If you don’t have one you can create one. 

Step 17: Go to Dashboards and Check the Preview.

That’s it you are done.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!