Skip to content

Commit e5ce1c6

Browse files
committed
update
1 parent 1de4c21 commit e5ce1c6

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
ms.service: key-vault
3+
ms.topic: include
4+
ms.date: 07/07/2022
5+
author: msmbaldwin
6+
ms.author: mbaldwin
7+
---
8+
9+
### Count key vault resources
10+
11+
This query uses `count` instead of `summarize` to count the number of records returned. Only key vaults are included in the count.
12+
13+
```kusto
14+
Resources
15+
| where type =~ 'microsoft.keyvault/vaults'
16+
| count
17+
```
18+
19+
# [Azure CLI](#tab/azure-cli)
20+
21+
```azurecli-interactive
22+
az graph query -q "Resources | where type =~ 'microsoft.keyvault/vaults' | count"
23+
```
24+
25+
# [Azure PowerShell](#tab/azure-powershell)
26+
27+
```azurepowershell-interactive
28+
Search-AzGraph -Query "Resources | where type =~ 'microsoft.keyvault/vaults' | count"
29+
```
30+
31+
# [Portal](#tab/azure-portal)
32+
33+
34+
35+
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20where%20type%20%3d%7e%20%27microsoft.keyvault%2fvaults%27%0a%7c%20count" target="_blank">portal.azure.com</a>
36+
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20where%20type%20%3d%7e%20%27microsoft.keyvault%2fvaults%27%0a%7c%20count" target="_blank">portal.azure.us</a>
37+
- Microsoft Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20where%20type%20%3d%7e%20%27microsoft.keyvault%2fvaults%27%0a%7c%20count" target="_blank">portal.azure.cn</a>
38+
39+
---
40+
41+
### Key vaults with subscription name
42+
43+
The following query shows a complex use of `join` with **kind** as _leftouter_. The query limits the joined table to subscriptions resources and with `project` to include only the original field _subscriptionId_ and the _name_ field renamed to _SubName_. The field rename avoids `join` adding it as _name1_ since the field already exists in _resources_. The original table is filtered with `where` and the following `project` includes columns from both tables. The query result is all key vaults displaying type, the name of the key vault, and the name of the subscription it's in.
44+
45+
```kusto
46+
Resources
47+
| join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project SubName=name, subscriptionId) on subscriptionId
48+
| where type == 'microsoft.keyvault/vaults'
49+
| project type, name, SubName
50+
```
51+
52+
# [Azure CLI](#tab/azure-cli)
53+
54+
```azurecli-interactive
55+
az graph query -q "Resources | join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project SubName=name, subscriptionId) on subscriptionId | where type == 'microsoft.keyvault/vaults' | project type, name, SubName"
56+
```
57+
58+
# [Azure PowerShell](#tab/azure-powershell)
59+
60+
```azurepowershell-interactive
61+
Search-AzGraph -Query "Resources | join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project SubName=name, subscriptionId) on subscriptionId | where type == 'microsoft.keyvault/vaults' | project type, name, SubName"
62+
```
63+
64+
# [Portal](#tab/azure-portal)
65+
66+
67+
68+
- Azure portal: <a href="https://portal.azure.com/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20join%20kind%3dleftouter%20(ResourceContainers%20%7c%20where%20type%3d%3d%27microsoft.resources%2fsubscriptions%27%20%7c%20project%20SubName%3dname%2c%20subscriptionId)%20on%20subscriptionId%0a%7c%20where%20type%20%3d%3d%20%27microsoft.keyvault%2fvaults%27%0a%7c%20project%20type%2c%20name%2c%20SubName" target="_blank">portal.azure.com</a>
69+
- Azure Government portal: <a href="https://portal.azure.us/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20join%20kind%3dleftouter%20(ResourceContainers%20%7c%20where%20type%3d%3d%27microsoft.resources%2fsubscriptions%27%20%7c%20project%20SubName%3dname%2c%20subscriptionId)%20on%20subscriptionId%0a%7c%20where%20type%20%3d%3d%20%27microsoft.keyvault%2fvaults%27%0a%7c%20project%20type%2c%20name%2c%20SubName" target="_blank">portal.azure.us</a>
70+
- Azure operated by 21Vianet portal: <a href="https://portal.azure.cn/#blade/HubsExtension/ArgQueryBlade/query/Resources%0a%7c%20join%20kind%3dleftouter%20(ResourceContainers%20%7c%20where%20type%3d%3d%27microsoft.resources%2fsubscriptions%27%20%7c%20project%20SubName%3dname%2c%20subscriptionId)%20on%20subscriptionId%0a%7c%20where%20type%20%3d%3d%20%27microsoft.keyvault%2fvaults%27%0a%7c%20project%20type%2c%20name%2c%20SubName" target="_blank">portal.azure.cn</a>
71+
72+
---

0 commit comments

Comments
 (0)