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
@@ -47,13 +47,13 @@ Install the latest *Az.Network* Azure PowerShell module by using this command:
47
47
48
48
## Create a resource group
49
49
50
-
Before you can create an Azure Virtual Network Manager instance, you have to create a resource group to host it. Create a resource group by using [New-AzResourceGroup](/powershell/module/az.Resources/New-azResourceGroup). This example creates a resource group named *vnm-learn-eastus-001ResourceGroup* in the East US location:
50
+
Before you can create an Azure Virtual Network Manager instance, you have to create a resource group to host it. Create a resource group by using [New-AzResourceGroup](/powershell/module/az.Resources/New-azResourceGroup). This example creates a resource group named *resource-group* in the *West US 2* region:
51
51
52
52
```azurepowershell
53
-
54
-
$location = "East US"
53
+
# Create a resource group
54
+
$location = "West US 2"
55
55
$rg = @{
56
-
Name = 'rg-learn-eastus-001'
56
+
Name = 'resource-group'
57
57
Location = $location
58
58
}
59
59
New-AzResourceGroup @rg
@@ -65,11 +65,10 @@ New-AzResourceGroup @rg
65
65
Define the scope and access type for the Azure Virtual Network Manager instance by using [New-AzNetworkManagerScope](/powershell/module/az.network/new-aznetworkmanagerscope). This example defines a scope with a single subscription and sets the access type to *Connectivity*. Replace `<subscription_id>` with the ID of the subscription that you want to manage through Azure Virtual Network Manager.
Create a Virtual Network Manager instance by using [New-AzNetworkManager](/powershell/module/az.network/new-aznetworkmanager). This example creates an instance named *vnm-learn-eastus-001* in the East US location:
82
+
Create a Virtual Network Manager instance by using [New-AzNetworkManager](/powershell/module/az.network/new-aznetworkmanager). This example creates an instance named *network-manager* in the *West US 2* region:
Create three virtual networks by using [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). This example creates virtual networks named *vnet-learn-prod-eastus-001*, *vnet-learn-prod-eastus-002*, and *vnet-learn-test-eastus-003* in the East US location. If you already have virtual networks that you want create a mesh network with, you can skip to the next section.
97
+
Create three virtual networks by using [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). This example creates virtual networks named *vnet-spoke-001*, *vnet-spoke-002*, and *vnet-hub-001* in the *West US 2* region. If you already have virtual networks that you want create a mesh network with, you can skip to the next section.
To complete the configuration of the virtual networks, create a subnet configuration named *default* with a subnet address prefix of */24* by using [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig). Then, use [Set-AzVirtualNetwork](/powershell/module/az.network/set-azvirtualnetwork) to apply the subnet configuration to the virtual network.
Virtual Network Manager applies configurations to groups of virtual networks by placing them in network groups. Create a network group by using [New-AzNetworkManagerGroup](/powershell/module/az.network/new-aznetworkmanagergroup). This example creates a network group named *ng-learn-prod-eastus-001* in the East US location:
158
+
Virtual Network Manager applies configurations to groups of virtual networks by placing them in network groups. Create a network group by using [New-AzNetworkManagerGroup](/powershell/module/az.network/new-aznetworkmanagergroup). This example creates a network group named *network-group* in the West US 2 region:
160
159
161
160
```azurepowershell
162
161
$ng = @{
163
-
Name = 'ng-learn-prod-eastus-001'
164
-
ResourceGroupName = $rg.Name
162
+
Name = 'network-group'
163
+
ResourceGroupName = $rg.ResourceGroupName
165
164
NetworkManagerName = $networkManager.Name
166
165
}
167
166
$ng = New-AzNetworkManagerGroup @ng
168
167
```
169
168
170
169
## Define membership for a mesh configuration
171
170
172
-
After you create your network group, you define its membership by adding virtual networks. You can add these networks manually or by using Azure Policy.
173
-
174
-
# [Manual membership](#tab/manualmembership)
175
-
176
-
### Add membership manually
177
-
178
-
In this task, you add the static members *vnet-learn-prod-eastus-001* and *vnet-learn-prod-eastus-002* to the network group *ng-learn-prod-eastus-001* by using [New-AzNetworkManagerStaticMember](/powershell/module/az.network/new-aznetworkmanagerstaticmember).
171
+
In this task, you add the static members *vnet-spoke-001* and *vnet-spoke-002* to the network group *network-group* by using [New-AzNetworkManagerStaticMember](/powershell/module/az.network/new-aznetworkmanagerstaticmember).
179
172
180
173
Static members must have a unique name that's scoped to the network group. We recommend that you use a consistent hash of the virtual network ID. This approach uses the Azure Resource Manager template's `uniqueString()` implementation.
181
174
@@ -188,101 +181,30 @@ Static members must have a unique name that's scoped to the network group. We re
188
181
```
189
182
190
183
```azurepowershell
191
-
$sm_vnet001 = @{
192
-
Name = Get-UniqueString $vnet_learn_prod_eastus_001.Id
### Create a policy definition for dynamic membership
215
-
216
-
By using [Azure Policy](concept-azure-policy-integration.md), you define a condition to dynamically add two virtual networks to your network group when the name of the virtual network includes *-prod*.
217
-
218
-
> [!NOTE]
219
-
> We recommend that you scope all of your conditionals to scan for only type `Microsoft.Network/virtualNetworks`, for efficiency.
220
-
221
-
1. Define the conditional statement and store it in a variable:
1. Create the Azure Policy definition by using the conditional statement defined in the previous step and using [New-AzPolicyDefinition](/powershell/module/az.resources/new-azpolicydefinition).
247
-
248
-
In this example, the policy definition name is prefixed with *poldef-learn-prod-* and suffixed with a unique string that's generated from a consistent hash in the network group ID. Policy resources must have a scope unique name.
249
-
250
-
```azurepowershell
251
-
function Get-UniqueString ([string]$id, $length=13)
In this task, you create a connectivity configuration with the network group *ng-learn-prod-eastus-001* by using [New-AzNetworkManagerConnectivityConfiguration](/powershell/module/az.network/new-aznetworkmanagerconnectivityconfiguration) and [New-AzNetworkManagerConnectivityGroupItem](/powershell/module/az.network/new-aznetworkmanagerconnectivitygroupitem):
207
+
In this task, you create a connectivity configuration with the network group *network-group* by using [New-AzNetworkManagerConnectivityConfiguration](/powershell/module/az.network/new-aznetworkmanagerconnectivityconfiguration) and [New-AzNetworkManagerConnectivityGroupItem](/powershell/module/az.network/new-aznetworkmanagerconnectivitygroupitem):
286
208
287
209
1. Create a connectivity group item:
288
210
@@ -304,8 +226,8 @@ In this task, you create a connectivity configuration with the network group *ng
304
226
305
227
```azurepowershell
306
228
$config = @{
307
-
Name = 'cc-learn-prod-eastus-001'
308
-
ResourceGroupName = $rg.Name
229
+
Name = 'connectivity-configuration'
230
+
ResourceGroupName = $rg.ResourceGroupName
309
231
NetworkManagerName = $networkManager.Name
310
232
ConnectivityTopology = 'Mesh'
311
233
AppliesToGroup = $configGroup
@@ -321,77 +243,26 @@ Commit the configuration to the target regions by using `Deploy-AzNetworkManager
If you no longer need the Azure Virtual Network Manager instance and it's associate resources, delete the resource group that contains them. Deleting the resource group also deletes the resources that you created.
390
261
391
-
1. If you no longer need the resource that you created, delete the resource group by using [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup):
262
+
1.Delete the resource group using [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup):
0 commit comments