Skip to content

Commit 4862592

Browse files
author
Michael Bender
committed
Updates - Added Note entry - Added 3rd example
1 parent 5e68f8f commit 4862592

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

articles/virtual-network-manager/how-to-exclude-elements.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,28 @@ List of supported operators:
5959
6060
## Basic editor
6161

62-
Assume you have the following virtual networks in your subscription. Each virtual network has either a *Production* or *Test* tag associated. You only want to select virtual networks with the Production tag and contain **VNet-A** in the name.
63-
62+
Assume you have the following virtual networks in your subscription. Each virtual network has an associated tag named **environment** with the respective value of *Production* or *Test*.
6463
* VNet-A-EastUS - *Production*
6564
* VNet-A-WestUS - *Production*
6665
* VNet-B-WestUS - *Test*
6766
* VNet-C-WestUS - *Test*
6867
* VNetA - *Production*
6968
* VNetB - *Test*
7069

71-
To begin using the basic editor to create your conditional statement, you need to create a new network group.
72-
73-
1. Go to your Azure Virtual Network Manager instance and select **Network Groups** under *Settings*. Then select **+ Create** to create a new network group.
70+
You only want to select virtual networks that contain **VNet-A** in the name. To begin using the basic editor to create your conditional statement, you need to create a new network group.
7471

72+
1. Go to your Azure Virtual Network Manager instance and select **Network Groups** under **Settings**. Then select **+ Create** to create a new network group.
7573
1. Enter a **Name** and an optional **Description** for the network group, and select **Add**.
7674
1. Select the network group from the list and select **Create Azure Policy**.
7775
1. Enter a **Policy name** and leave the **Scope** selections unless changes are needed.
78-
1. Under **Criteria**, select **Tags** from the drop-down under *Parameter* and then select **Exist** from the drop-down under *Operator*.
79-
80-
1. Enter **Prod** under *Condition*, then select **Save**.
81-
1. After a few minutes, select your network group and select **Group Members** under *Settings*. You should only see VNet-A-EastUS, VNet-A-WestUS, and VNetA show up in the list.
76+
1. Under **Criteria**, select **Name** from the drop-down under **Parameter** and then select **Contains** from the drop-down under *Operator*.
77+
1. Enter **VNET-A** under **Condition**, then select **Save**.
78+
1. After a few minutes, select your network group and select **Group Members** under **Settings**. You should only see VNet-A-EastUS, VNet-A-WestUS, and VNetA show up in the list.
8279

83-
> [!NOTE]
84-
> The **basic editor** is only available during the creation of an Azure Policy.
80+
> [!IMPORTANT]
81+
> The **basic editor** is only available during the creation of an Azure Policy. Once a policy is created, all edits will be done using JSON in the **Policies** section of virtual network manager or via Azure Policy.
82+
>
83+
> When using the basic editor, your query options will be limited through the portal experience. For complex queries like creating a network group for VNets based on a customer-defined tag, you can used the advanced editor. Learn more about [Azure Policy definition structure](../governance/policy/concepts/definition-structure.md).
8584
8685
## Advanced editor
8786

@@ -108,7 +107,7 @@ The advanced editor can be used to select virtual network during the creation of
108107

109108
The `"allOf"` parameter contains both the conditional statements that are separated by the **AND** logical operator.
110109

111-
1. To add another conditional statement for a *Name* field *not containing* **WestUS**, enter the following into the advanced editor:
110+
1. To add another conditional statement for a **Name** field *not containing* **WestUS**, enter the following into the advanced editor:
112111

113112
```json
114113
{
@@ -156,7 +155,7 @@ This example uses the **OR** logical operator to separate two conditional statem
156155
},
157156
{
158157
"field": "Name",
159-
"contains": "VNetA"
158+
"contains": "VNetB"
160159
}
161160
]
162161
}
@@ -183,7 +182,7 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
183182
},
184183
{
185184
"field": "Name",
186-
"contains": "VNetA"
185+
"contains": "VNetB"
187186
}
188187
]
189188
},
@@ -194,9 +193,31 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
194193
]
195194
}
196195
```
197-
198196
Both `"allOf"` and `"anyOf"` are used in the code. Since the **AND** operator is last in the list, it is on the outer part of the code containing the two conditional statements with the **OR** operator.
199197

198+
### Example 3: Using custom tag values with advanced editor
199+
200+
In this example, a conditional statement is created that finds virtual networks where a tag exists for **environment** AND the **environment** tag equals **production**.
201+
202+
* Advanced editor:
203+
204+
```json
205+
206+
{
207+
"allOf": [
208+
{
209+
"field": "tags['Environment']",
210+
"exists": true
211+
},
212+
{
213+
"field": "tags['environment']",
214+
"equals": "production"
215+
}
216+
]
217+
}
218+
219+
```
220+
200221
> [!NOTE]
201222
> Conditionals should filter on resource type Microsoft.Network/virtualNetwork to improve efficiency.
202223
> This condition is prepended for you on any conditionals specified through the portal.
2.3 KB
Loading
555 Bytes
Loading

0 commit comments

Comments
 (0)