- 23 Feb 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
Resource Graph Query
- Updated on 23 Feb 2024
- 1 Minute 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.
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.
- You can also create it from the Resource Graph Queries section if there is any existing resource graph query associated.
- 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.
The resource graph license consumption 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.