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
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
21
23
22
24
- If you didn't create the subnet you would like to delegate to an Azure service, you need the following permission: `Microsoft.Network/virtualNetworks/subnets/write`. The built-in [Network Contributor](../role-based-access-control/built-in-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json#network-contributor) role also contains the necessary permissions.
- This how-to article requires version 2.31.0 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
28
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
29
+
30
+
- If you didn't create the subnet you would like to delegate to an Azure service, you need the following permission: `Microsoft.Network/virtualNetworks/subnets/write`. The built-in [Network Contributor](../role-based-access-control/built-in-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json#network-contributor) role also contains the necessary permissions.
27
31
28
32
- Azure PowerShell installed locally or Azure Cloud Shell.
29
33
@@ -32,83 +36,59 @@ Subnet delegation gives explicit permissions to the service to create service-sp
32
36
- Ensure your `Az.Network` module is 4.3.0 or later. To verify the installed module, use the command `Get-InstalledModule -Name "Az.Network"`. If the module requires an update, use the command `Update-Module -Name Az.Network` if necessary.
33
37
34
38
If you choose to install and use PowerShell locally, this article requires the Azure PowerShell module version 5.4.1 or later. Run `Get-Module -ListAvailable Az` to find the installed version. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell). If you're running PowerShell locally, you also need to run `Connect-AzAccount` to create a connection with Azure.
1. Sign-in to the [Azure portal](https://portal.azure.com).
42
-
43
-
1. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results.
44
-
45
-
1. Select **+ Create**.
46
-
47
-
1. Enter or select the following information in the **Basics** tab of **Create virtual network**:
41
+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
48
42
49
-
| Setting | Value |
50
-
| ------- | ----- |
51
-
|**Project details**||
52
-
| Subscription | Select your subscription. |
53
-
| Resource group | Select **Create new**. </br> Enter **myResourceGroup** in **Name**. </br> Select **OK**. |
54
-
|**Instance details**||
55
-
| Name | Enter **myVNet**. |
56
-
| Region | Select **East US 2**|
43
+
- If you didn't create the subnet you would like to delegate to an Azure service, you need the following permission: `Microsoft.Network/virtualNetworks/subnets/write`. The built-in [Network Contributor](../role-based-access-control/built-in-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json#network-contributor) role also contains the necessary permissions.
57
44
58
-
1. Select **Next: Security**, then **Next: IP Addresses**.
Create a resource group with [New-AzResourceGroup](/cli/azure/group). An Azure resource group is a logical container into which Azure resources are deployed and managed.
84
62
85
-
The following example creates a resource group named **myResourceGroup** in the **eastus2** location:
63
+
Create a resource group with [`New-AzResourceGroup`](/cli/azure/group). An Azure resource group is a logical container into which Azure resources are deployed and managed.
64
+
65
+
The following example creates a resource group named **test-rg** in the **eastus2** location:
86
66
87
67
```azurepowershell-interactive
88
68
$rg = @{
89
-
Name = 'myResourceGroup'
69
+
Name = 'test-rg'
90
70
Location = 'eastus2'
91
71
}
92
72
New-AzResourceGroup @rg
93
73
```
94
74
### Create virtual network
95
75
96
-
Create a virtual network named **myVnet** with a subnet named **mySubnet** using [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) in the **myResourceGroup** using [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork).
76
+
Create a virtual network named **vnet-1** with a subnet named **subnet-1** using [`New-AzVirtualNetworkSubnetConfig`](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) in the **test-rg** using [`New-AzVirtualNetwork`](/powershell/module/az.network/new-azvirtualnetwork).
97
77
98
-
The IP address space for the virtual network is **10.1.0.0/16**. The subnet within the virtual network is **10.1.0.0/24**.
78
+
The IP address space for the virtual network is **10.0.0.0/16**. The subnet within the virtual network is **10.0.0.0/24**.
99
79
100
80
```azurepowershell-interactive
101
81
$sub = @{
102
-
Name = 'mySubnet'
103
-
AddressPrefix = '10.1.0.0/24'
82
+
Name = 'subnet-1'
83
+
AddressPrefix = '10.0.0.0/24'
104
84
}
105
85
$subnet = New-AzVirtualNetworkSubnetConfig @sub
106
86
107
87
$net = @{
108
-
Name = 'myVNet'
109
-
ResourceGroupName = 'myResourceGroup'
88
+
Name = 'vnet-1'
89
+
ResourceGroupName = 'test-rg'
110
90
Location = 'eastus2'
111
-
AddressPrefix = '10.1.0.0/16'
91
+
AddressPrefix = '10.0.0.0/16'
112
92
Subnet = $subnet
113
93
}
114
94
New-AzVirtualNetwork @net
@@ -118,27 +98,28 @@ New-AzVirtualNetwork @net
118
98
119
99
### Create a resource group
120
100
121
-
Create a resource group with [az group create](/cli/azure/group). An Azure resource group is a logical container into which Azure resources are deployed and managed.
101
+
Create a resource group with [`az group create`](/cli/azure/group). An Azure resource group is a logical container into which Azure resources are deployed and managed.
122
102
123
-
The following example creates a resource group named **myResourceGroup** in the **eastu2** location:
103
+
The following example creates a resource group named **test-rg** in the **eastu2** location:
124
104
125
105
```azurecli-interactive
126
106
az group create \
127
-
--name myResourceGroup \
107
+
--name test-rg \
128
108
--location eastus2
129
109
```
130
110
131
111
### Create a virtual network
132
-
Create a virtual network named **myVnet** with a subnet named **mySubnet** in the **myResourceGroup** using [az network vnet create](/cli/azure/network/vnet).
112
+
113
+
Create a virtual network named **vnet-1** with a subnet named **subnet-1** in the **test-rg** using [`az network vnet create`](/cli/azure/network/vnet).
133
114
134
115
```azurecli-interactive
135
116
az network vnet create \
136
-
--resource-group myResourceGroup \
117
+
--resource-group test-rg \
137
118
--location eastus2 \
138
-
--name myVNet \
139
-
--address-prefix 10.1.0.0/16 \
140
-
--subnet-name mySubnet \
141
-
--subnet-prefix 10.1.0.0/24
119
+
--name vnet-1 \
120
+
--address-prefix 10.0.0.0/16 \
121
+
--subnet-name subnet-1 \
122
+
--subnet-prefix 10.0.0.0/24
142
123
```
143
124
144
125
---
@@ -153,11 +134,11 @@ In this section, you delegate the subnet that you created in the preceding secti
153
134
154
135
1. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results.
155
136
156
-
1. Select **myVNet**.
137
+
1. Select **vnet-1**.
157
138
158
139
1. Select **Subnets** in **Settings**.
159
140
160
-
1. Select **mySubnet**.
141
+
1. Select **subnet-1**.
161
142
162
143
1. Enter or select the following information:
163
144
@@ -170,17 +151,17 @@ In this section, you delegate the subnet that you created in the preceding secti
Use [Add-AzDelegation](/powershell/module/az.network/add-azdelegation) to update the subnet named **mySubnet** with a delegation named **myDelegation** to an Azure service. In this example **Microsoft.Sql/managedInstances** is used for the example delegation:
154
+
Use [`Add-AzDelegation`](/powershell/module/az.network/add-azdelegation) to update the subnet named **subnet-1** with a delegation named **myDelegation** to an Azure service. In this example **Microsoft.Sql/managedInstances** is used for the example delegation:
Id : /subscriptions/3bf09329-ca61-4fee-88cb-7e30b9ee305b/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet/delegations/myDelegation
199
+
Id : /subscriptions/3bf09329-ca61-4fee-88cb-7e30b9ee305b/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/vnet-1/subnets/subnet-1/delegations/myDelegation
Use [az network vnet subnet update](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) to update the subnet named **mySubnet** with a delegation to an Azure service. In this example **Microsoft.Sql/managedInstances** is used for the example delegation:
204
+
Use [`az network virtual network subnet update`](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) to update the subnet named **subnet-1** with a delegation to an Azure service. In this example **Microsoft.Sql/managedInstances** is used for the example delegation:
224
205
225
206
```azurecli-interactive
226
207
az network vnet subnet update \
227
-
--resource-group myResourceGroup \
228
-
--name mySubnet \
229
-
--vnet-name myVNet \
208
+
--resource-group test-rg \
209
+
--name subnet-1 \
210
+
--vnet-name vnet-1 \
230
211
--delegations Microsoft.Sql/managedInstances
231
212
```
232
213
233
-
To verify the delegation was applied, use [az network vnet subnet show](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-show). Verify the service is delegated to the subnet in the property **serviceName**:
214
+
To verify the delegation was applied, use [`az network vnet subnet show`](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-show). Verify the service is delegated to the subnet in the property **serviceName**:
234
215
235
216
```azurecli-interactive
236
217
az network vnet subnet show \
237
-
--resource-group myResourceGroup \
238
-
--name mySubnet \
239
-
--vnet-name myVNet \
218
+
--resource-group test-rg \
219
+
--name subnet-1 \
220
+
--vnet-name vnet-1 \
240
221
--query delegations
241
222
```
242
223
@@ -249,10 +230,10 @@ az network vnet subnet show \
Use [az network vnet subnet update](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) to remove the delegation from the subnet named **mySubnet**:
316
+
Use [`az network vnet subnet update`](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) to remove the delegation from the subnet named **subnet-1**:
336
317
337
318
```azurecli-interactive
338
319
az network vnet subnet update \
339
-
--resource-group myResourceGroup \
340
-
--name mySubnet \
341
-
--vnet-name myVNet \
320
+
--resource-group test-rg \
321
+
--name subnet-1 \
322
+
--vnet-name vnet-1 \
342
323
--remove delegations
343
324
```
344
-
To verify the delegation was removed, use [az network vnet subnet show](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-show). Verify the service is removed from the subnet in the property **serviceName**:
325
+
To verify the delegation was removed, use [`az network vnet subnet show`](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-show). Verify the service is removed from the subnet in the property **serviceName**:
345
326
346
327
```azurecli-interactive
347
328
az network vnet subnet show \
348
-
--resource-group myResourceGroup \
349
-
--name mySubnet \
350
-
--vnet-name myVNet \
329
+
--resource-group test-rg \
330
+
--name subnet-1 \
331
+
--vnet-name vnet-1 \
351
332
--query delegations
352
333
```
353
334
Output from command is a null bracket:
@@ -357,15 +338,7 @@ Output from command is a null bracket:
357
338
358
339
---
359
340
360
-
## Clean up resources
361
-
362
-
When no longer needed, delete the resource group and all resources it contains:
363
-
364
-
1. Enter *myResourceGroup* in the **Search** box at the top of the Azure portal. When you see **myResourceGroup** in the search results, select it.
365
-
366
-
1. Select **Delete resource group**.
367
-
368
-
1. Enter *myResourceGroup* for **TYPE THE RESOURCE GROUP NAME:** and select **Delete**.
0 commit comments