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/virtual-network-manager/how-to-exclude-elements.md
+36-15Lines changed: 36 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,29 +59,28 @@ List of supported operators:
59
59
60
60
## Basic editor
61
61
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*.
64
63
* VNet-A-EastUS - *Production*
65
64
* VNet-A-WestUS - *Production*
66
65
* VNet-B-WestUS - *Test*
67
66
* VNet-C-WestUS - *Test*
68
67
* VNetA - *Production*
69
68
* VNetB - *Test*
70
69
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.
74
71
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.
75
73
1. Enter a **Name** and an optional **Description** for the network group, and select **Add**.
76
74
1. Select the network group from the list and select **Create Azure Policy**.
77
75
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.
82
79
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).
85
84
86
85
## Advanced editor
87
86
@@ -108,7 +107,7 @@ The advanced editor can be used to select virtual network during the creation of
108
107
109
108
The `"allOf"` parameter contains both the conditional statements that are separated by the **AND** logical operator.
110
109
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:
112
111
113
112
```json
114
113
{
@@ -156,7 +155,7 @@ This example uses the **OR** logical operator to separate two conditional statem
156
155
},
157
156
{
158
157
"field": "Name",
159
-
"contains": "VNetA"
158
+
"contains": "VNetB"
160
159
}
161
160
]
162
161
}
@@ -183,7 +182,7 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
183
182
},
184
183
{
185
184
"field": "Name",
186
-
"contains": "VNetA"
185
+
"contains": "VNetB"
187
186
}
188
187
]
189
188
},
@@ -194,9 +193,31 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
194
193
]
195
194
}
196
195
```
197
-
198
196
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.
199
197
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
+
200
221
> [!NOTE]
201
222
> Conditionals should filter on resource type Microsoft.Network/virtualNetwork to improve efficiency.
202
223
> This condition is prepended for you on any conditionals specified through the portal.
0 commit comments