You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/governance/resource-graph/how-to/get-resource-changes.md
+137-8Lines changed: 137 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Get resource changes
3
3
description: Understand how to find when a resource was changed and query the list of resource configuration changes at scale
4
-
ms.date: 01/27/2022
4
+
ms.date: 02/18/2022
5
5
ms.topic: how-to
6
6
---
7
7
# Get resource changes
@@ -44,7 +44,7 @@ Monitor.
44
44
45
45
## Find detected change events and view change details
46
46
47
-
When a resource is created, updated, or deleted, a new change resource (Microsoft.Resources/changes) is created to extend the modified resource and represent the changed properties.
47
+
When a resource is created, updated, or deleted, a new change resource (Microsoft.Resources/changes) is created to extend the modified resource and represent the changed properties. Change records should be available in under five minutes.
48
48
49
49
Example change resource property bag:
50
50
@@ -99,13 +99,142 @@ Each change resource has the following properties:
99
99
-**previousResourceSnapshotId** - Contains the ID of the resource snapshot that was used as the previous state of the resource.
100
100
-**newResourceSnapshotId** - Contains the ID of the resource snapshot that was used as the new state of the resource.
101
101
102
-
## Resource Graph Query samples
102
+
## How to query changes using Resource Graph
103
+
### Prerequisites
104
+
- To enable Azure PowerShell to query Azure Resource Graph, the [module must be added](../first-query-powershell.md#add-the-resource-graph-module).
105
+
- To enable Azure CLI to query Azure Resource Graph, the [extension must be added](../first-query-azurecli.md#add-the-resource-graph-extension).
103
106
104
-
With Resource Graph, you can query the **ResourceChanges** table to filter or sort by any of the change resource properties:
107
+
### Run your Resource Graph query
108
+
It's time to try out a tenant-based Resource Graph query of the **resourcechanges** table. The query returns the first five most recent Azure resource changes with the change time, change type, target resource ID, target resource type, and change details of each change record. To query by
109
+
[management group](../../management-groups/overview.md) or subscription, use the `-ManagementGroup`
110
+
or `-Subscription` parameters.
111
+
112
+
1. Run your first Azure Resource Graph query:
113
+
114
+
# [Azure CLI](#tab/azure-cli)
115
+
```azurecli-interactive
116
+
# Login first with az login if not using Cloud Shell
> The order of the query commands is important. In this example,
209
+
> the `order by` must come before the `limit` command. This command order first orders the query results by the change time and
210
+
> then limits them to ensure that you get the five *most recent* results.
211
+
212
+
213
+
When the final query is run several times, assuming that nothing in your environment is changing,
214
+
the results returned are consistent and ordered by the **properties.changeAttributes.timestamp** (or your user-defined name of **changeTime**) property, but still limited to the
215
+
top five results.
216
+
217
+
218
+
> [!NOTE]
219
+
> If the query does not return results from a subscription you already have access to, then note
220
+
> that the `Search-AzGraph` PowerShell cmdlet defaults to subscriptions in the default context. To see the list of
221
+
> subscription IDs which are part of the default context run this
222
+
> `(Get-AzContext).Account.ExtendedProperties.Subscriptions` If you wish to search across all the
223
+
> subscriptions you have access to, one can set the PSDefaultParameterValues for `Search-AzGraph`
Resource Graph Explorer also provides a clean interface for converting the results of some queries into a chart that can be pinned to an Azure dashboard.
228
+
-[Create a chart from the Resource Graph query](../first-query-portal.md#create-a-chart-from-the-resource-graph-query)
229
+
-[Pin the query visualization to a dashboard](../first-query-portal.md#pin-the-query-visualization-to-a-dashboard)
230
+
231
+
## Resource Graph query samples
232
+
233
+
With Resource Graph, you can query the **resourcechanges** table to filter or sort by any of the change resource properties:
0 commit comments