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
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.
57
57
58
-
```azurepowershell-interactive
58
+
```azurepowershell
59
59
60
60
$location = "East US"
61
61
$rg = @{
@@ -70,7 +70,7 @@ New-AzResourceGroup @rg
70
70
71
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.
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.
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, 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
164
165
-
```azurepowershell-interactive
165
+
```azurepowershell
166
166
$ng = @{
167
167
Name = 'ng-learn-prod-eastus-001'
168
168
ResourceGroupName = $rg.Name
@@ -183,15 +183,15 @@ In this task, you add the static members **vnet-learn-prod-eastus-001** and **vn
183
183
> [!NOTE]
184
184
> 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.
185
185
186
-
```azurepowershell-interactive
186
+
```azurepowershell
187
187
function Get-UniqueString ([string]$id, $length=13)
Name = Get-UniqueString $vnet_learn_prod_eastus_002.Id
208
208
ResourceGroupName = $rg.Name
@@ -223,7 +223,7 @@ Using [Azure Policy](concept-azure-policy-integration.md), you define a conditio
223
223
> [!NOTE]
224
224
> It is recommended to scope all of your conditionals to only scan for type `Microsoft.Network/virtualNetworks` for efficiency.
225
225
226
-
```azurepowershell-interactive
226
+
```azurepowershell
227
227
$conditionalMembership = '{
228
228
"if": {
229
229
"allOf": [
@@ -248,7 +248,7 @@ Using [Azure Policy](concept-azure-policy-integration.md), you define a conditio
248
248
249
249
1. Create the Azure Policy definition using the conditional statement defined in the last step using [New-AzPolicyDefinition](/powershell/module/az.resources/new-azpolicydefinition). In this example, the policy definition name is prefixed with **poldef-learn-prod-** and suffixed with a unique string generated from a consistent hash the network group ID. Policy resources must have a scope unique name.
250
250
251
-
```azurepowershell-interactive
251
+
```azurepowershell
252
252
function Get-UniqueString ([string]$id, $length=13)
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