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
Copy file name to clipboardExpand all lines: articles/virtual-network/virtual-network-manage-subnet.md
+43-15Lines changed: 43 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.custom:
10
10
- devx-track-azurecli
11
11
- devx-track-azurepowershell
12
12
- ignite-2023
13
-
ms.date: 11/15/2023
13
+
ms.date: 04/15/2025
14
14
ms.author: allensu
15
15
---
16
16
@@ -23,17 +23,20 @@ All Azure resources in a virtual network are deployed into subnets within the vi
23
23
# [Portal](#tab/azure-portal)
24
24
25
25
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
26
+
26
27
- An existing Azure virtual network. To create one, see [Quickstart: Create a virtual network by using the Azure portal](quick-create-portal.md).
28
+
27
29
- To run the procedures, sign in to the [Azure portal](https://portal.azure.com) with your Azure account.
28
30
29
31
# [Azure CLI](#tab/azure-cli)
30
32
31
33
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
34
+
32
35
- An existing Azure virtual network. To create one, see [Quickstart: Create a virtual network by using Azure CLI](quick-create-cli.md).
33
36
34
37
You can run the commands either in the [Azure Cloud Shell](/azure/cloud-shell/overview) or from Azure CLI on your computer.
35
38
36
-
- Azure Cloud Shell is a free interactive shell that has common Azure tools preinstalled and configured to use with your account. To run the commands in the Cloud Shell, select **Open Cloudshell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
39
+
- Azure Cloud Shell is a free interactive shell that has common Azure tools preinstalled and configured to use with your account. To run the commands in the Cloud Shell, select **Open Cloud shell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
37
40
38
41
- If you [install Azure CLI locally](/cli/azure/install-azure-cli) to run the commands, you need Azure CLI version 2.31.0 or later. Run [az version](/cli/azure/reference-index?#az-version) to find your installed version, and run [az upgrade](/cli/azure/reference-index?#az-upgrade) to upgrade.
39
42
@@ -42,11 +45,12 @@ You can run the commands either in the [Azure Cloud Shell](/azure/cloud-shell/ov
42
45
# [PowerShell](#tab/azure-powershell)
43
46
44
47
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
48
+
45
49
- An existing Azure virtual network. To create one, see [Quickstart: Create a virtual network by using Azure PowerShell](quick-create-powershell.md).
46
50
47
51
You can run the commands either in the [Azure Cloud Shell](/azure/cloud-shell/overview) or from PowerShell on your computer.
48
52
49
-
- Azure Cloud Shell is a free interactive shell that has common Azure tools preinstalled and configured to use with your account. To run the commands in the Cloud Shell, select **Open Cloudshell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
53
+
- Azure Cloud Shell is a free interactive shell that has common Azure tools preinstalled and configured to use with your account. To run the commands in the Cloud Shell, select **Open Cloud shell** at the upper-right corner of a code block. Select **Copy** to copy the code, and paste it into Cloud Shell to run it. You can also run the Cloud Shell from within the Azure portal.
50
54
51
55
- If you [install Azure PowerShell locally](/powershell/azure/install-azure-powershell) to run the commands, you need Azure PowerShell module version 5.4.1 or later. Run `Get-Module -ListAvailable Az` to find your installed version. If you need to upgrade, see [Update the Azure PowerShell module](/powershell/azure/install-Az-ps#update-the-azure-powershell-module).
52
56
@@ -59,7 +63,7 @@ You can run the commands either in the [Azure Cloud Shell](/azure/cloud-shell/ov
59
63
60
64
### Permissions
61
65
62
-
To do tasks on subnets, your account must be assigned to the [Network contributor role](../role-based-access-control/built-in-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json#network-contributor) or to a [custom role](../role-based-access-control/custom-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json)that's assigned the appropriate actions in the following list:
66
+
To do tasks on subnets, your account must be assigned to the [Network contributor role](../role-based-access-control/built-in-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json#network-contributor) or to a [custom role](../role-based-access-control/custom-roles.md?toc=%2fazure%2fvirtual-network%2ftoc.json) assigned the appropriate actions in the following list:
1. Then associate the subnet configuration to the virtual network with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork).
102
119
103
-
```azurepowershell-interactive
104
-
Set-AzVirtualNetwork -VirtualNetwork $vnet
105
-
```
120
+
```azurepowershell-interactive
121
+
Set-AzVirtualNetwork -VirtualNetwork $vnet
122
+
```
106
123
107
124
---
108
125
@@ -151,7 +168,7 @@ You can change the following subnet settings after the subnet is created:
151
168
| --- | --- |
152
169
|**Subnet address range**| If no resources are deployed within the subnet, you can change the address range. If any resources exist in the subnet, you must first either move the resources to another subnet or delete them from the subnet. The steps you take to move or delete a resource vary depending on the resource. To learn how to move or delete resources that are in subnets, read the documentation for each resource type.|
153
170
|**Add IPv6 address space**, **NAT gateway**, **Network security group**, and **Route table**| You can add IPv6, NAT gateway, NSG, or route table support after you create the subnet.|
154
-
|**Service endpoints**| To enable a service endpoint for an existing subnet, ensure that no critical tasks are running on any resource in the subnet. Service endpoints switch routes on every network interface in the subnet. The service endpoints change from using the default route with the `0.0.0.0/0` address prefix and next hop type of `Internet` to using a new route with the address prefix of the service and a next hop type of `VirtualNetworkServiceEndpoint`.<br><br>During the switch, any open TCP connections may be terminated. The service endpoint isn't enabled until traffic to the service for all network interfaces updates with the new route. For more information, see [Virtual network traffic routing](virtual-networks-udr-overview.md).|
171
+
|**Service endpoints**| To enable a service endpoint for an existing subnet, ensure that no critical tasks are running on any resource in the subnet. Service endpoints switch routes on every network interface in the subnet. The service endpoints change from using the default route with the `0.0.0.0/0` address prefix and next hop type of `Internet` to using a new route with the address prefix of the service and a next hop type of `VirtualNetworkServiceEndpoint`.<br><br>During the switch, any open TCP connections might be terminated. The service endpoint isn't enabled until traffic to the service for all network interfaces updates with the new route. For more information, see [Virtual network traffic routing](virtual-networks-udr-overview.md).|
155
172
|**Subnet delegation**| You can modify subnet delegation to enable zero or multiple delegations. If a resource for a service is already deployed in the subnet, you can't add or remove subnet delegations until you remove all the resources for the service. To delegate for a different service in the portal, select the service you want to delegate to from the popup list. |
156
173
|**Network policy for private endpoints**| You can change private endpoint network policy after subnet creation.|
157
174
@@ -162,25 +179,36 @@ You can change the following subnet settings after the subnet is created:
162
179
You can delete a subnet only if there are no resources in the subnet. If resources are in the subnet, you must delete those resources before you can delete the subnet. The steps you take to delete a resource vary depending on the resource. To learn how to delete the resources, see the documentation for each resource type.
163
180
164
181
1. In the [Azure portal](https://portal.azure.com), search for and select *virtual networks*.
182
+
165
183
1. On the **Virtual networks** page, select the virtual network you want to delete a subnet from.
184
+
166
185
1. On the virtual network's page, select **Subnets** from the left navigation.
186
+
167
187
1. On the **Subnets** page, select the subnet you want to delete.
188
+
168
189
1. Select **Delete**, and then select **Yes** in the confirmation dialog box.
169
190
170
191
# [Azure CLI](#tab/azure-cli)
171
192
172
193
Run the [az network vnet subnet delete](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-delete) command.
Run the [Remove-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/remove-azvirtualnetworksubnetconfig?toc=%2fazure%2fvirtual-network%2ftoc.json) command and then set the configuration.
0 commit comments