Skip to content

Commit 18325cd

Browse files
authored
Merge pull request #222784 from mbender-ms/avnm-update-az-pol-editor
Virtual Network Manager - Updates for Azure Policy creation clarfications
2 parents e66b63d + d14d34f commit 18325cd

File tree

3 files changed

+89
-53
lines changed

3 files changed

+89
-53
lines changed

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

Lines changed: 89 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -59,67 +59,80 @@ 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.
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*.
63+
* myVNet01-EastUS - *Production*
64+
* myVNet01-WestUS - *Production*
65+
* myVNet02-WestUS - *Test*
66+
* myVNet03-WestUS - *Test*
6367

64-
* VNet-A-EastUS - *Production*
65-
* VNet-A-WestUS - *Production*
66-
* VNet-B-WestUS - *Test*
67-
* VNet-C-WestUS - *Test*
68-
* VNetA - *Production*
69-
* VNetB - *Test*
70-
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.
68+
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.
7469

70+
1. Go to your Azure Virtual Network Manager instance and select **Network Groups** under **Settings**. Then select **+ Create** to create a new network group.
7571
1. Enter a **Name** and an optional **Description** for the network group, and select **Add**.
7672
1. Select the network group from the list and select **Create Azure Policy**.
7773
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.
74+
1. Under **Criteria**, select **Name** from the drop-down under **Parameter** and then select **Contains** from the drop-down under *Operator*.
75+
1. Enter **WestUS** under **Condition**, then select **Save**.
76+
1. After a few minutes, select your network group and select **Group Members** under **Settings**. You should only see myVNet01-WestUS, myVNet02-WestUS, and myVNet03-WestUS show up in the list.
8277

83-
> [!NOTE]
84-
> The **basic editor** is only available during the creation of an Azure Policy.
78+
> [!IMPORTANT]
79+
> 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.
80+
>
81+
> When using the basic editor, your condition options will be limited through the portal experience. For complex conditions 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).
8582
8683
## Advanced editor
8784

88-
The advanced editor can be used to select virtual network during the creation of a network group or when updating an existing network group. Based in [JSON](../governance/policy/concepts/assignment-structure.md), the advanced editor is useful for creating and updating complex Azure Policy conditional statements by experienced users.
85+
The advanced editor can be used to select virtual networks during the creation of a network group or when updating an existing network group. Based in [JSON](../governance/policy/concepts/assignment-structure.md), the advanced editor is useful for creating and updating complex Azure Policy conditional statements by experienced users.
86+
87+
### Create a new policy with advanced editor
88+
89+
1. Go to your Azure Virtual Network Manager instance and select **Network Groups** under **Settings**. Then select **+ Create** to create a new network group.
90+
1. Enter a **Name** and an optional **Description** for the network group, and select **Add**.
91+
1. Select the network group from the list and select **Create Azure Policy**.
92+
1. Enter a **Policy name** and leave the **Scope** selections unless changes are needed.
93+
1. Under **Criteria**, select **Advanced (JSON) editor** to open the editor.
94+
1. Enter the following JSON code into the text box and select **Save**:
95+
96+
```json
97+
{
98+
"allOf": [
99+
{
100+
"field": "Name",
101+
"contains": "myVNet01"
102+
}
103+
]
104+
}
105+
```
106+
1. After a few minutes, select your network group and select **Group Members** under **Settings**. You should only see myVNet01-WestUS and myVNet01-EastUS.
89107

90-
1. Select the network group created in the previous section. Then select the **Conditional statements** tab.
108+
### Edit an existing policy
91109

92-
1. You'll see the conditional statements for the network group in the advance editor view as followed:
110+
1. Select the network group created in the previous section. Then select the **Policies** tab.
111+
1. Select the policy created in the previous section.
112+
1. You'll see the conditional statements for the network group in the advance editor view as follows:
93113

94114
```json
95-
{
96-
"allOf": [
97-
{
98-
"field": "tags['Environment']",
99-
"exists": true
100-
},
101-
{
102-
"field": "Name",
103-
"contains": "VNet-A"
104-
}
105-
]
106-
}
115+
[
116+
{
117+
"allOf": [
118+
{
119+
"field": "Name",
120+
"contains": "myVNet01"
121+
}
122+
]
123+
}
124+
]
107125
```
108126

109-
The `"allOf"` parameter contains both the conditional statements that are separated by the **AND** logical operator.
110-
111-
1. To add another conditional statement for a *Name* field *not containing* **WestUS**, enter the following into the advanced editor:
127+
1. To add another conditional statement for a **Name** field *not containing* **WestUS**, enter the following into the advanced editor:
112128

113129
```json
114130
{
115131
"allOf": [
116-
{
117-
"field": "tags['Environment']",
118-
"exists": true
119-
},
132+
120133
{
121134
"field": "Name",
122-
"contains": "VNet-A"
135+
"contains": "VNet01"
123136
},
124137
{
125138
"field": "Name",
@@ -129,14 +142,15 @@ The advanced editor can be used to select virtual network during the creation of
129142
}
130143
```
131144

132-
1. Then select **Evaluate**. You should only see VNet-A-EastUS virtual network in the list.
133-
134-
1. Select **Review + save** and then select **Save** once validation has passed.
135-
136-
See [Parameter and operators](#parameters) for the complete list of parameters and operators you can use with the advanced editor. See below for more examples:
145+
The `"allOf"` parameter contains both the conditional statements that are separated by the **AND** logical operator.
146+
1. Select Save.
147+
1. After a few minutes, select your network group and select **Group Members** under **Settings**. You should only see myVNet01-EastUS.
137148

149+
See [Parameter and operators](#parameters) for the complete list of parameters and operators you can use with the advanced editor.
138150
## More examples
139151

152+
Here are more examples of conditional statements in the advanced editor.
153+
140154
### Example 1: OR operator only
141155

142156
This example uses the **OR** logical operator to separate two conditional statements.
@@ -152,11 +166,11 @@ This example uses the **OR** logical operator to separate two conditional statem
152166
"anyOf": [
153167
{
154168
"field": "Name",
155-
"contains": "VNet-A"
169+
"contains": "myVNet01"
156170
},
157171
{
158172
"field": "Name",
159-
"contains": "VNetA"
173+
"contains": "myVNet02"
160174
}
161175
]
162176
}
@@ -179,11 +193,11 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
179193
"anyOf": [
180194
{
181195
"field": "Name",
182-
"contains": "VNet-A"
196+
"contains": "myVNet01"
183197
},
184198
{
185199
"field": "Name",
186-
"contains": "VNetA"
200+
"contains": "myVNet02"
187201
}
188202
]
189203
},
@@ -194,12 +208,34 @@ The `"anyOf"` parameter contains both the conditional statements that are separa
194208
]
195209
}
196210
```
197-
198211
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.
199212

200-
> [!NOTE]
201-
> Conditionals should filter on resource type Microsoft.Network/virtualNetwork to improve efficiency.
202-
> This condition is prepended for you on any conditionals specified through the portal.
213+
### Example 3: Using custom tag values with advanced editor
214+
215+
In this example, a conditional statement is created that finds virtual networks where the name includes **myVNet** AND the **environment** tag equals **production**.
216+
217+
* Advanced editor:
218+
219+
```json
220+
221+
{
222+
"allOf": [
223+
{
224+
"field": "Name",
225+
"contains": "myVNet"
226+
},
227+
{
228+
"field": "tags['environment']",
229+
"equals": "production"
230+
}
231+
]
232+
}
233+
234+
```
235+
236+
> [!NOTE]
237+
> Conditionals should filter on resource type Microsoft.Network/virtualNetwork to improve efficiency.
238+
> This condition is prepended for you on any conditionals specified through the portal.
203239
## Next steps
204240

205241
- Learn about [Network groups](concept-network-groups.md).
2.3 KB
Loading
555 Bytes
Loading

0 commit comments

Comments
 (0)