Skip to content

Commit b307c90

Browse files
authored
Merge pull request #278348 from davidsmatlak/ds-copy-policy-include-file-20240614
Copy ARG include file
2 parents 136134c + edb730c commit b307c90

File tree

6 files changed

+89
-2
lines changed

6 files changed

+89
-2
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
ms.service: azure-policy
3+
ms.topic: include
4+
ms.date: 06/04/2024
5+
author: davidsmatlak
6+
ms.author: davidsmatlak
7+
---
8+
9+
### Policy exemptions per assignment
10+
11+
Lists the number of exemptions for each assignment.
12+
13+
```kusto
14+
PolicyResources
15+
| where type == 'microsoft.authorization/policyexemptions'
16+
| summarize count() by tostring(properties.policyAssignmentId)
17+
```
18+
19+
For more information about using scopes with Azure CLI or Azure PowerShell, go to [Count Azure resources](../../../../resource-graph/samples/starter.md#count-azure-resources).
20+
21+
# [Azure CLI](#tab/azure-cli)
22+
23+
Use the `--management-groups` parameter with an Azure management group ID or tenant ID. In this example, the `tenantid` variable stores the tenant ID.
24+
25+
```azurecli-interactive
26+
tenantid="$(az account show --query tenantId --output tsv)"
27+
az graph query -q "policyresources | where type == 'microsoft.authorization/policyexemptions' | summarize count() by tostring(properties.policyAssignmentId)" --management-groups $tenantid
28+
```
29+
30+
# [Azure PowerShell](#tab/azure-powershell)
31+
32+
By default, PowerShell get results for all subscriptions in your tenant but you can also include the `-UseTenantScope` parameter.
33+
34+
```azurepowershell-interactive
35+
Search-AzGraph -Query "policyresources | where type == 'microsoft.authorization/policyexemptions' | summarize count() by tostring(properties.policyAssignmentId)" -UseTenantScope
36+
```
37+
38+
# [Portal](#tab/azure-portal)
39+
40+
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20summarize%20count%28%29%20by%20tostring%28properties.policyAssignmentId%29" target="_blank">portal.azure.com</a>
41+
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20summarize%20count%28%29%20by%20tostring%28properties.policyAssignmentId%29" target="_blank">portal.azure.us</a>
42+
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20summarize%20count%28%29%20by%20tostring%28properties.policyAssignmentId%29" target="_blank">portal.azure.cn</a>
43+
44+
---
45+
46+
### Policy exemptions that expire within 90 days
47+
48+
Lists the name and expiration date.
49+
50+
```kusto
51+
PolicyResources
52+
| where type == 'microsoft.authorization/policyexemptions'
53+
| extend expiresOnC = todatetime(properties.expiresOn)
54+
| where isnotnull(expiresOnC)
55+
| where expiresOnC >= now() and expiresOnC < now(+90d)
56+
| project name, expiresOnC
57+
```
58+
59+
# [Azure CLI](#tab/azure-cli)
60+
61+
```azurecli-interactive
62+
az graph query -q "policyresources | where type == 'microsoft.authorization/policyexemptions' | extend expiresOnC = todatetime(properties.expiresOn) | where isnotnull(expiresOnC) | where expiresOnC >= now() and expiresOnC < now(+90d) | project name, expiresOnC"
63+
```
64+
65+
# [Azure PowerShell](#tab/azure-powershell)
66+
67+
```azurepowershell-interactive
68+
Search-AzGraph -Query "policyresources | where type == 'microsoft.authorization/policyexemptions' | extend expiresOnC = todatetime(properties.expiresOn) | where isnotnull(expiresOnC) | where expiresOnC >= now() and expiresOnC < now(+90d) | project name, expiresOnC"
69+
```
70+
71+
# [Portal](#tab/azure-portal)
72+
73+
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20extend%20expiresOnC%20%3D%20todatetime%28properties.expiresOn%29%0D%0A%7C%20where%20isnotnull%28expiresOnC%29%0D%0A%7C%20where%20expiresOnC%20%3E%3D%20now%28%29%20and%20expiresOnC%20%3C%20now%28%2B90d%29%0D%0A%7C%20project%20name%2C%20expiresOnC" target="_blank">portal.azure.com</a>
74+
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20extend%20expiresOnC%20%3D%20todatetime%28properties.expiresOn%29%0D%0A%7C%20where%20isnotnull%28expiresOnC%29%0D%0A%7C%20where%20expiresOnC%20%3E%3D%20now%28%29%20and%20expiresOnC%20%3C%20now%28%2B90d%29%0D%0A%7C%20project%20name%2C%20expiresOnC" target="_blank">portal.azure.us</a>
75+
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/policyresources%0D%0A%7C%20where%20type%20%3D%3D%20%27microsoft.authorization%2Fpolicyexemptions%27%0D%0A%7C%20extend%20expiresOnC%20%3D%20todatetime%28properties.expiresOn%29%0D%0A%7C%20where%20isnotnull%28expiresOnC%29%0D%0A%7C%20where%20expiresOnC%20%3E%3D%20now%28%29%20and%20expiresOnC%20%3C%20now%28%2B90d%29%0D%0A%7C%20project%20name%2C%20expiresOnC" target="_blank">portal.azure.cn</a>
76+
77+
---

articles/governance/resource-graph/reference/supported-tables-resources.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Supported Azure Resource Manager resource types
33
description: Provide a list of the Azure Resource Manager resource types supported by Azure Resource Graph and Change History.
44
ms.date: 06/05/2024
55
ms.topic: reference
6+
author: davidsmatlak
7+
ms.author: davidsmatlak
68
ms.custom: generated
79
---
810

articles/governance/resource-graph/samples/advanced.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Advanced query samples
33
description: Use Azure Resource Graph to run some advanced queries, including working with columns, listing tags used, and matching resources with regular expressions.
44
ms.date: 06/05/2024
55
ms.topic: sample
6+
author: davidsmatlak
7+
ms.author: davidsmatlak
68
ms.custom: devx-track-azurepowershell, devx-track-azurecli
79
---
810

articles/governance/resource-graph/samples/samples-by-category.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: List of sample Azure Resource Graph queries by category
33
description: List sample queries for Azure Resource-Graph. Categories include Tags, Azure Advisor, Key Vault, Kubernetes, Guest Configuration, and more.
44
ms.date: 06/05/2024
55
ms.topic: sample
6+
author: davidsmatlak
7+
ms.author: davidsmatlak
68
ms.custom: generated
79
---
810

@@ -69,7 +71,7 @@ Otherwise, use <kbd>Ctrl</kbd>-<kbd>F</kbd> to use your browser's search feature
6971

7072
[!INCLUDE [azure-resource-graph-samples-cat-azure-policy](../../includes/resource-graph/samples/bycat/azure-policy.md)]
7173

72-
[!INCLUDE [policy-resources-exemption-query](../../includes/policy/policy-resources-exemption-query.md)]
74+
[!INCLUDE [policy-resources-exemption-query](../../includes/resource-graph/samples/query/policy-resources-exemption-query.md)]
7375

7476
## Azure Policy guest configuration
7577

articles/governance/resource-graph/samples/samples-by-table.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: List of sample Azure Resource Graph queries by table
33
description: List sample queries for Azure Resource-Graph. Tables include Resources, ResourceContainers, PolicyResources, and more.
44
ms.date: 06/05/2024
55
ms.topic: sample
6+
author: davidsmatlak
7+
ms.author: davidsmatlak
68
ms.custom: generated
79
---
810

@@ -89,7 +91,7 @@ details, see [Resource Graph tables](../concepts/query-language.md#resource-grap
8991

9092
[!INCLUDE [azure-resource-graph-samples-table-policyresources](../../includes/resource-graph/samples/bytable/policyresources.md)]
9193

92-
[!INCLUDE [policy-resources-exemption-query](../../includes/policy/policy-resources-exemption-query.md)]
94+
[!INCLUDE [policy-resources-exemption-query](../../includes/resource-graph/samples/query/policy-resources-exemption-query.md)]
9395

9496
## ResourceContainers
9597

articles/governance/resource-graph/samples/starter.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Starter query samples
33
description: Use Azure Resource Graph to run some starter queries, including counting resources, ordering resources, or by a specific tag.
44
ms.date: 06/05/2024
55
ms.topic: sample
6+
author: davidsmatlak
7+
ms.author: davidsmatlak
68
ms.custom: devx-track-azurepowershell, devx-track-azurecli
79
---
810

0 commit comments

Comments
 (0)