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
# Quickstart: Create a mesh network with Azure Virtual Network Manager using Azure PowerShell
@@ -25,143 +25,160 @@ In this quickstart, you deploy three virtual networks and use Azure Virtual Netw
25
25
## Prerequisites
26
26
27
27
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
28
-
* Run `Connect-AzAccount` to create a local connection with Azure.
29
28
30
29
> [!IMPORTANT]
31
-
> Perform this quickstart using Powershell locally, not through Azure Cloud Shell. The version of `Az.Network` in Azure Cloud Shell does not currently support the Azure Virtual Network Manager cmdlets.
30
+
> Perform this quickstart using PowerShell locally, not through Azure Cloud Shell. The version of `Az.Network` in Azure Cloud Shell does not currently support the Azure Virtual Network Manager cmdlets.
32
31
32
+
## Sign in to your Azure account and select your subscription
33
+
34
+
To begin your configuration, sign in to your Azure account. Use the following examples to help you connect:
35
+
36
+
Login to Azure
37
+
38
+
```azurepowershell
39
+
Connect-AzAccount
40
+
```
41
+
42
+
Connect to your subscription
43
+
44
+
```azurepowershell
45
+
Set-AzContext -Subscription <subscription name or id>
46
+
```
33
47
## Install Azure PowerShell module
34
48
35
49
Install the latest *Az.Network* Azure PowerShell module using this command:
Before you can create an Azure Virtual Network Manager, you have to create a resource group to host the Network Manager. Create a resource group with [New-AzResourceGroup](/powershell/module/az.Resources/New-azResourceGroup). This example creates a resource group named **myAVNMResourceGroup** in the **WestUS** location.
56
+
Before you can create an Azure Virtual Network Manager, you have to create a resource group to host the Network Manager. Create a resource group with [New-AzResourceGroup](/powershell/module/az.Resources/New-azResourceGroup). This example creates a resource group named **vnm-learn-eastus-001ResourceGroup** in the **WestUS** location.
44
57
45
58
```azurepowershell-interactive
46
59
47
-
$location = "West US"
60
+
$location = "East US"
48
61
$rg = @{
49
-
Name = 'myAVNMResourceGroup'
62
+
Name = 'rg-learn-eastus-001'
50
63
Location = $location
51
64
}
52
65
New-AzResourceGroup @rg
53
66
54
67
```
55
68
56
-
## Create Virtual Network Manager
69
+
## Define the scope and access type
57
70
58
-
1.Define the scope and access type this Azure Virtual Network Manager instance have. You can choose to create the scope with subscriptions group or management group or a combination of both. Create the scope by using New-AzNetworkManagerScope.
71
+
Define the scope and access type for the Azure Virtual Network Manager instance with [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 **<subscriptionid>** with the subscription ID of the subscription you want to manage with Azure Virtual Network Manager.
1. Create the Virtual Network Manager with New-AzNetworkManager. This example creates an Azure Virtual Network Manager named **myAVNM** in the West US location.
85
+
```
86
+
## Create Virtual Network Manager
87
+
88
+
Create the Virtual Network Manager with [New-AzNetworkManager](/powershell/module/az.network/new-aznetworkmanager). This example creates an Azure Virtual Network Manager named **vnm-learn-eastus-001** in the East Us location.
78
89
79
-
```azurepowershell-interactive
80
-
$avnm = @{
81
-
Name = 'myAVNM'
82
-
ResourceGroupName = $rg.Name
83
-
NetworkManagerScope = $scope
84
-
NetworkManagerScopeAccess = $access
85
-
Location = $location
86
-
}
87
-
$networkmanager = New-AzNetworkManager @avnm
88
-
```
90
+
```azurepowershell-interactive
91
+
$avnm = @{
92
+
Name = 'vnm-learn-eastus-001'
93
+
ResourceGroupName = $rg.Name
94
+
NetworkManagerScope = $scope
95
+
NetworkManagerScopeAccess = $access
96
+
Location = $location
97
+
}
98
+
$networkmanager = New-AzNetworkManager @avnm
99
+
```
89
100
90
101
## Create three virtual networks
91
102
92
-
Create three virtual networks with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). This example creates virtual networks named **VNetA**, **VNetB** and **VNetC** in the **West US** location. If you already have virtual networks you want create a mesh network with, you can skip to the next section.
103
+
Create three virtual networks with [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 you want create a mesh network with, you can skip to the next section.
To complete the configuration of the virtual networks, add a /24 subnet to each one. Create a subnet configuration named **default** with [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig).
134
+
To complete the configuration of the virtual networks, create a subnet configuration named **default** with [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig) with a subnet address prefix of **/24**. 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 VNets by placing them in network groups. Create a network group with [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.
164
+
165
+
```azurepowershell-interactive
166
+
$ng = @{
167
+
Name = 'ng-learn-prod-eastus-001'
168
+
ResourceGroupName = $rg.Name
169
+
NetworkManagerName = $networkManager.Name
170
+
}
171
+
$ng = New-AzNetworkManagerGroup @ng
172
+
```
152
173
153
-
1. Create a network group to add virtual networks to.
174
+
## Define membership for a mesh configuration
154
175
155
-
```azurepowershell-interactive
156
-
$ng = @{
157
-
Name = 'myNetworkGroup'
158
-
ResourceGroupName = $rg.Name
159
-
NetworkManagerName = $networkManager.Name
160
-
}
161
-
$networkgroup = New-AzNetworkManagerGroup @ng
162
-
```
163
-
164
-
### Option 1: Static membership
176
+
Once your network group is created, you define a network group's membership by adding virtual networks. Choose one of the options: *[Manually add membership](#manually-add-membership)* or *[Create policy to dynamically add members](#create-azure-policy-for-dynamic-membership)* with Azure Policy.
177
+
# [Manual membership](#tab/manualmembership)
178
+
179
+
### Manually add membership
180
+
181
+
In this task, you manually add two virtual networks for your Mesh configuration to your network group using these steps:
165
182
166
183
1. Add the static member to the network group with the following commands:
167
184
1. Static members must have a network group scoped unique name. It's recommended to use a consistent hash of the virtual network ID. This is an approach using the ARM Templates uniqueString() implementation.
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** using these steps:
211
231
212
232
1. Define the conditional statement and store it in a variable.
@@ -356,7 +376,7 @@ If you no longer need the Azure Virtual Network Manager, you need to make sure a
356
376
3. Remove the network group with Remove-AzNetworkManagerGroup.
357
377
358
378
```azurepowershell-interactive
359
-
Remove-AzNetworkManagerGroup $networkGroup.Id
379
+
Remove-AzNetworkManagerGroup ng.Id
360
380
```
361
381
362
382
4. Delete the network manager instance with Remove-AzNetworkManager.
@@ -368,7 +388,7 @@ If you no longer need the Azure Virtual Network Manager, you need to make sure a
368
388
5. If you no longer need the resource created, delete the resource group with [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup).
0 commit comments