- 19 Nov 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
Resource Graph Query
- Updated on 19 Nov 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
Introduction
Azure Resource Graph is an Azure service intended to manage Azure resource(s) by providing highly responsive resource exploration. It offers a unified API and a potent query language that lets you quickly and effectively retrieve data about your resources across a specified set of subscriptions.
Use Case Scenario
Here's a real-time example of an Azure Resource Graph query:
resourcechanges
| where properties.changeType == "Delete" and properties.changeAttributes.timestamp > ago(1d)
This query retrieves information about Azure resources that have been deleted in the last day.
Let's break down this query:
- 'resourcechanges': This is the table in Azure Resource Graph that contains information about all Azure resources that have been created, updated (or) deleted.
- | where properties.changeType == "Delete" and properties.changeAttributes.timestamp > ago(1d): This selects the resource types deleted in the last day.
As a result of the above query, users can easily identify deleted resources and get their complete information, such as resource name and type.
This is a simple example, but Azure Resource Graph can handle much more complicated queries involving multiple tables and advanced filtering and aggregation techniques.
Associating existing queries
Resource graph queries available in an Azure subscrption can be associated to a Business Application in a similar way as the other Azure resource types with the help of Add resources flow, Create Business Application flow and Edit Business Application flow.
Creating a query
- A resource graph query can be created in a Business Application by using the Add dropdown in the Resources section of a Business Application.
- Give the query a unique name and an optional description. Enter the query and select the Azure subscription and resource group to which the query should be assigned as an Azure resource.
License consumption for resource graph queries works similar to other Azure resource types.
Executing a query
Provide valid query data and hit the Run button. Different chart types can be used to display the query results.
Updating an existing query
The Update button allows the addition of new query data to an existing resource graph query.
Saving a new query from an existing one
A resource graph query can be created from an existing one by executing a new query in it and clicking the Save button.
Resource Dashboard
Users can keep track of the query results by using a dashboard to visualize the resource graph query.
Query Monitoring
The associated resource graph queries can be monitored by configuring rules to it in Monitoring section. The threshold values can be specified based on users needs.