Skip to content

Commit 4befa87

Browse files
authored
Merge pull request #86983 from DCtheGeek/dmc-arg-displaynames
Adding Include parameter example
2 parents 0b3572e + a862ead commit 4befa87

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

articles/governance/resource-graph/first-query-azurecli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Docker image](https://hub.docker.com/r/microsoft/azure-cli/), or locally install
3737
az extension add --name resource-graph
3838
```
3939

40-
1. Validate that the extension has been installed and is the expected version (at least **0.1.11**):
40+
1. Validate that the extension has been installed and is the expected version (at least **1.0.0**):
4141

4242
```azurecli-interactive
4343
# Check the extension list (note that you may have other extensions installed)

articles/governance/resource-graph/first-query-powershell.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The Resource Graph module for PowerShell is **Az.ResourceGraph**.
4848
Install-Module -Name Az.ResourceGraph
4949
```
5050

51-
1. Validate that the module has been imported and is the correct version (0.7.3):
51+
1. Validate that the module has been imported and is the latest version (0.7.5):
5252

5353
```azurepowershell-interactive
5454
# Get a list of commands for the imported Az.ResourceGraph module

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Advanced query samples
3-
description: Use Azure Resource Graph to run some advanced queries, including VMSS capacity, listing all tags used, and matching virtual machines with regular expressions.
3+
description: Use Azure Resource Graph to run some advanced queries, including virtual machine scale set capacity, listing all tags used, and matching virtual machines with regular expressions.
44
author: DCtheGeek
55
ms.author: dacoulte
6-
ms.date: 01/23/2019
6+
ms.date: 08/29/2019
77
ms.topic: quickstart
88
ms.service: resource-graph
99
manager: carmonm
@@ -23,7 +23,8 @@ We'll walk through the following advanced queries:
2323
> - [List all tag names](#list-all-tags)
2424
> - [Virtual machines matched by regex](#vm-regex)
2525
26-
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free) before you begin.
26+
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free)
27+
before you begin.
2728

2829
[!INCLUDE [az-powershell-update](../../../../includes/updated-for-az.md)]
2930

@@ -39,8 +40,8 @@ validate your shell environment of choice.
3940

4041
This query looks for virtual machine scale set resources and gets various details including the
4142
virtual machine size and the capacity of the scale set. The query uses the `toint()` function to
42-
cast the capacity to a number so that it can be sorted. Finally, the columns are renamed into
43-
custom named properties.
43+
cast the capacity to a number so that it can be sorted. Finally, the columns are renamed into custom
44+
named properties.
4445

4546
```kusto
4647
where type=~ 'microsoft.compute/virtualmachinescalesets'
@@ -77,8 +78,9 @@ Search-AzGraph -Query "project tags | summarize buildschema(tags)"
7778

7879
## <a name="vm-regex"></a>Virtual machines matched by regex
7980

80-
This query looks for virtual machines that match a [regular expression](/dotnet/standard/base-types/regular-expression-language-quick-reference) (known as _regex_).
81-
The **matches regex \@** allows us to define the regex to match, which is `^Contoso(.*)[0-9]+$`. That regex definition is explained as:
81+
This query looks for virtual machines that match a [regular expression](/dotnet/standard/base-types/regular-expression-language-quick-reference)
82+
(known as _regex_). The **matches regex \@** allows us to define the regex to match, which is `^Contoso(.*)[0-9]+$`.
83+
That regex definition is explained as:
8284

8385
- `^` - Match must start at the beginning of the string.
8486
- `Contoso` - The case-sensitive string.
@@ -105,8 +107,29 @@ az graph query -q "where type =~ 'microsoft.compute/virtualmachines' and name ma
105107
Search-AzGraph -Query "where type =~ 'microsoft.compute/virtualmachines' and name matches regex @'^Contoso(.*)[0-9]+$' | project name | order by name asc"
106108
```
107109

110+
## <a name="displaynames"></a>Include the tenant and subscription names with DisplayNames
111+
112+
This query uses the new **Include** parameter with option _DisplayNames_ to add
113+
**subscriptionDisplayName** and **tenantDisplayName** to the results. This parameter is only
114+
available for Azure CLI and Azure PowerShell.
115+
116+
```azurecli-interactive
117+
az graph query -q "limit 1" --include displayNames
118+
```
119+
120+
```azurepowershell-interactive
121+
Search-AzGraph -Query "limit 1" -Include DisplayNames
122+
```
123+
124+
> [!NOTE]
125+
> If the query doesn't use **project** to specify the returned properties,
126+
> **subscriptionDisplayName** and **tenantDisplayName** are automatically included in the results.
127+
> If the query does use **project**, each of the _DisplayName_ fields must be explicitly included in
128+
> the **project** or they won't be returned in the results, even when the **Include** parameter is
129+
> used.
130+
108131
## Next steps
109132

110133
- See samples of [Starter queries](starter.md)
111134
- Learn more about the [query language](../concepts/query-language.md)
112-
- Learn to [explore resources](../concepts/explore-resources.md)
135+
- Learn to [explore resources](../concepts/explore-resources.md)

0 commit comments

Comments
 (0)