Skip to content

Commit 881a0b7

Browse files
author
Jill Grant
authored
Merge pull request #249185 from asudbring/vnet-delegation-update
Update of VNET subnet delegation how to for VNET portal create changes
2 parents 560e39e + 5a048bc commit 881a0b7

File tree

2 files changed

+132
-107
lines changed

2 files changed

+132
-107
lines changed

articles/virtual-network/manage-subnet-delegation.md

Lines changed: 80 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ services: virtual-network
66
author: asudbring
77
ms.service: virtual-network
88
ms.topic: how-to
9-
ms.date: 02/09/2023
9+
ms.date: 08/23/2023
1010
ms.author: allensu
11-
ms.custom: devx-track-azurepowershell, devx-track-azurecli, FY23 content-maintenance
11+
ms.custom: devx-track-azurepowershell, devx-track-azurecli
1212
---
1313

1414
# Add or remove a subnet delegation
@@ -17,13 +17,17 @@ Subnet delegation gives explicit permissions to the service to create service-sp
1717

1818
## Prerequisites
1919

20+
# [**Portal**](#tab/manage-subnet-delegation-portal)
21+
2022
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2123

2224
- 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.
2325

24-
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/articles/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)]
26+
# [**PowerShell**](#tab/manage-subnet-delegation-powershell)
2527

26-
- 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.
2731

2832
- Azure PowerShell installed locally or Azure Cloud Shell.
2933

@@ -32,83 +36,59 @@ Subnet delegation gives explicit permissions to the service to create service-sp
3236
- 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.
3337

3438
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.
39+
# [**Azure CLI**](#tab/manage-subnet-delegation-cli)
3540

36-
## Create the virtual network
37-
38-
In this section, you create a virtual network and the subnet that you'll later delegate to an Azure service.
39-
# [**Portal**](#tab/manage-subnet-delegation-portal)
40-
41-
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).
4842

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.
5744

58-
1. Select **Next: Security**, then **Next: IP Addresses**.
45+
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/articles/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)]
5946

60-
1. Select **Add an IP address space**, in the **Add an IP address space** pane, enter or select the following information, then select **Add**.
47+
- 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.
6148

62-
| Setting | Value |
63-
| ------- | ----- |
64-
| Address space type | Leave as default **IPV6**. |
65-
| Starting address | Enter **10.1.0.0**. |
66-
| Address space size | Select **/16**. |
49+
---
6750

68-
1. Select **+ Add subnet** in the new IP address space.
51+
## Create the virtual network
6952

70-
1. Enter or select the following information in **Add a subnet**. Then select **Add**.
53+
In this section, you create a virtual network and the subnet that you delegate to an Azure service.
7154

72-
| Setting | Value |
73-
| ------- | ----- |
74-
| Name | Enter **mySubnet**. |
75-
| Starting address | Enter **10.1.0.0**. |
76-
| Subnet size | Select **/16**. |
55+
# [**Portal**](#tab/manage-subnet-delegation-portal)
7756

78-
1. Select **Review + create**, then select **Create**.
57+
[!INCLUDE [virtual-network-create-tabs.md](../../includes/virtual-network-create-tabs.md)]
7958

8059
# [**PowerShell**](#tab/manage-subnet-delegation-powershell)
8160

8261
### Create a resource group
83-
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.
8462

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:
8666

8767
```azurepowershell-interactive
8868
$rg = @{
89-
Name = 'myResourceGroup'
69+
Name = 'test-rg'
9070
Location = 'eastus2'
9171
}
9272
New-AzResourceGroup @rg
9373
```
9474
### Create virtual network
9575

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).
9777

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**.
9979

10080
```azurepowershell-interactive
10181
$sub = @{
102-
Name = 'mySubnet'
103-
AddressPrefix = '10.1.0.0/24'
82+
Name = 'subnet-1'
83+
AddressPrefix = '10.0.0.0/24'
10484
}
10585
$subnet = New-AzVirtualNetworkSubnetConfig @sub
10686
10787
$net = @{
108-
Name = 'myVNet'
109-
ResourceGroupName = 'myResourceGroup'
88+
Name = 'vnet-1'
89+
ResourceGroupName = 'test-rg'
11090
Location = 'eastus2'
111-
AddressPrefix = '10.1.0.0/16'
91+
AddressPrefix = '10.0.0.0/16'
11292
Subnet = $subnet
11393
}
11494
New-AzVirtualNetwork @net
@@ -118,27 +98,28 @@ New-AzVirtualNetwork @net
11898

11999
### Create a resource group
120100

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.
122102

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:
124104

125105
```azurecli-interactive
126106
az group create \
127-
--name myResourceGroup \
107+
--name test-rg \
128108
--location eastus2
129109
```
130110

131111
### 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).
133114

134115
```azurecli-interactive
135116
az network vnet create \
136-
--resource-group myResourceGroup \
117+
--resource-group test-rg \
137118
--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
142123
```
143124

144125
---
@@ -153,11 +134,11 @@ In this section, you delegate the subnet that you created in the preceding secti
153134

154135
1. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results.
155136

156-
1. Select **myVNet**.
137+
1. Select **vnet-1**.
157138

158139
1. Select **Subnets** in **Settings**.
159140

160-
1. Select **mySubnet**.
141+
1. Select **subnet-1**.
161142

162143
1. Enter or select the following information:
163144

@@ -170,17 +151,17 @@ In this section, you delegate the subnet that you created in the preceding secti
170151

171152
# [**PowerShell**](#tab/manage-subnet-delegation-powershell)
172153

173-
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:
174155

175156
```azurepowershell-interactive
176157
$net = @{
177-
Name = 'myVNet'
178-
ResourceGroupName = 'myResourceGroup'
158+
Name = 'vnet-1'
159+
ResourceGroupName = 'test-rg'
179160
}
180161
$vnet = Get-AzVirtualNetwork @net
181162
182163
$sub = @{
183-
Name = 'mySubnet'
164+
Name = 'subnet-1'
184165
VirtualNetwork = $vnet
185166
}
186167
$subnet = Get-AzVirtualNetworkSubnetConfig @sub
@@ -194,14 +175,14 @@ $subnet = Add-AzDelegation @del
194175
195176
Set-AzVirtualNetwork -VirtualNetwork $vnet
196177
```
197-
Use [Get-AzDelegation](/powershell/module/az.network/get-azdelegation) to verify the delegation:
178+
Use [`Get-AzDelegation`](/powershell/module/az.network/get-azdelegation) to verify the delegation:
198179

199180
```azurepowershell-interactive
200181
$sub = @{
201-
Name = 'myVNet'
202-
ResourceGroupName = 'myResourceGroup'
182+
Name = 'vnet-1'
183+
ResourceGroupName = 'test-rg'
203184
}
204-
$subnet = Get-AzVirtualNetwork @sub | Get-AzVirtualNetworkSubnetConfig -Name 'mySubnet'
185+
$subnet = Get-AzVirtualNetwork @sub | Get-AzVirtualNetworkSubnetConfig -Name 'subnet-1'
205186
206187
$dg = @{
207188
Name ='myDelegation'
@@ -215,28 +196,28 @@ Get-AzDelegation @dg
215196
Actions : {Microsoft.Network/virtualNetworks/subnets/join/action}
216197
Name : myDelegation
217198
Etag : W/"9cba4b0e-2ceb-444b-b553-454f8da07d8a"
218-
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
219200
```
220201

221202
# [**Azure CLI**](#tab/manage-subnet-delegation-cli)
222203

223-
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:
224205

225206
```azurecli-interactive
226207
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 \
230211
--delegations Microsoft.Sql/managedInstances
231212
```
232213

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**:
234215

235216
```azurecli-interactive
236217
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 \
240221
--query delegations
241222
```
242223

@@ -249,10 +230,10 @@ az network vnet subnet show \
249230
"Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"
250231
],
251232
"etag": "W/\"30184721-8945-4e4f-9cc3-aa16b26589ac\"",
252-
"id": "/subscriptions/23250d6d-28f0-41dd-9776-61fc80805b6e/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVNet/subnets/mySubnet/delegations/0",
233+
"id": "/subscriptions/23250d6d-28f0-41dd-9776-61fc80805b6e/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/vnet-1/subnets/subnet-1/delegations/0",
253234
"name": "0",
254235
"provisioningState": "Succeeded",
255-
"resourceGroup": "myResourceGroup",
236+
"resourceGroup": "test-rg",
256237
"serviceName": "Microsoft.Sql/managedInstances",
257238
"type": "Microsoft.Network/virtualNetworks/subnets/delegations"
258239
}
@@ -263,19 +244,19 @@ az network vnet subnet show \
263244

264245
## Remove subnet delegation from an Azure service
265246

266-
In this section, you'll remove a subnet delegation for an Azure service.
247+
In this section, you remove a subnet delegation for an Azure service.
267248

268249
# [**Portal**](#tab/manage-subnet-delegation-portal)
269250

270251
1. Sign-in to the [Azure portal](https://portal.azure.com).
271252

272253
1. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results.
273254

274-
1. Select **myVNet**.
255+
1. Select **vnet-1**.
275256

276257
1. Select **Subnets** in **Settings**.
277258

278-
1. Select **mySubnet**.
259+
1. Select **subnet-1**.
279260

280261
1. Enter or select the following information:
281262

@@ -288,17 +269,17 @@ In this section, you'll remove a subnet delegation for an Azure service.
288269

289270
# [**PowerShell**](#tab/manage-subnet-delegation-powershell)
290271

291-
Use [Remove-AzDelegation](/powershell/module/az.network/remove-azdelegation) to remove the delegation from the subnet named **mySubnet**:
272+
Use [`Remove-AzDelegation`](/powershell/module/az.network/remove-azdelegation) to remove the delegation from the subnet named **subnet-1**:
292273

293274
```azurepowershell-interactive
294275
$net = @{
295-
Name = 'myVNet'
296-
ResourceGroupName = 'myResourceGroup'
276+
Name = 'vnet-1'
277+
ResourceGroupName = 'test-rg'
297278
}
298279
$vnet = Get-AzVirtualNetwork @net
299280
300281
$sub = @{
301-
Name = 'mySubnet'
282+
Name = 'subnet-1'
302283
VirtualNetwork = $vnet
303284
}
304285
$subnet = Get-AzVirtualNetworkSubnetConfig @sub
@@ -311,14 +292,14 @@ $subnet = Remove-AzDelegation @del
311292
312293
Set-AzVirtualNetwork -VirtualNetwork $vnet
313294
```
314-
Use [Get-AzDelegation](/powershell/module/az.network/get-azdelegation) to verify the delegation was removed:
295+
Use [`Get-AzDelegation`](/powershell/module/az.network/get-azdelegation) to verify the delegation was removed:
315296

316297
```azurepowershell-interactive
317298
$sub = @{
318-
Name = 'myVNet'
319-
ResourceGroupName = 'myResourceGroup'
299+
Name = 'vnet-1'
300+
ResourceGroupName = 'test-rg'
320301
}
321-
$subnet = Get-AzVirtualNetwork @sub | Get-AzVirtualNetworkSubnetConfig -Name 'mySubnet'
302+
$subnet = Get-AzVirtualNetwork @sub | Get-AzVirtualNetworkSubnetConfig -Name 'subnet-1'
322303
323304
$dg = @{
324305
Name ='myDelegation'
@@ -332,22 +313,22 @@ Get-AzDelegation: Sequence contains no matching element
332313

333314
# [**Azure CLI**](#tab/manage-subnet-delegation-cli)
334315

335-
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**:
336317

337318
```azurecli-interactive
338319
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 \
342323
--remove delegations
343324
```
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**:
345326

346327
```azurecli-interactive
347328
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 \
351332
--query delegations
352333
```
353334
Output from command is a null bracket:
@@ -357,15 +338,7 @@ Output from command is a null bracket:
357338

358339
---
359340

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**.
341+
[!INCLUDE [portal-clean-up.md](../../includes/portal-clean-up.md)]
369342

370343
## Next steps
371344
- Learn how to [manage subnets in Azure](virtual-network-manage-subnet.md).

0 commit comments

Comments
 (0)