A subnet is a logical division of an Azure virtual network (VNet). It receives part of the VNet’s local IP address range, and its range cannot overlap another subnet’s. Think of the VNet as a city’s roads and each subnet as the roads in one suburb: separate areas, still part of the same network. section 4.2
Divide a VNet when the separation has a purpose:
- Group resources by project or department, or separate services with different security requirements. Network security groups can apply traffic rules to a subnet. section 4.2.2 section 4.6
- Reserve a subnet for a service that requires delegation, such as an Azure SQL managed instance. section 4.2.2
- Leave room to grow. Adding resources later is common, while reallocating VNet addresses is hard work. section 4.2.2
Create and delegate a subnet
In Az PowerShell, retrieve the VNet with Get-AzVirtualNetwork, add a subnet with Add-AzVirtualNetworkSubnetConfig and an address prefix such as 10.0.1.0/24, then save the VNet with Set-AzVirtualNetwork. To delegate that subnet to Azure SQL managed instances, retrieve its configuration, call Add-AzDelegation with Microsoft.Sql/managedInstances, and save the VNet again. section 4.2 section 4.2.2
Listing 4.1 Delegating a subnet inside a VNet
PS C:\> $vnet = Get-AzVirtualNetwork -Name "AlpacaVNet" -ResourceGroupName "AlpacaRG" #1 PS C:\> $subnet = Get-AzVirtualNetworkSubnetConfig -Name "hairstyleSubnet" -VirtualNetwork $vnet #2 PS C:\> Add-AzDelegation -Name "hairstyleDelegation" -ServiceName "Microsoft.Sql/managedInstances" -Subnet $subnet #3 PS C:\> Set-AzVirtualNetwork -VirtualNetwork $vnet #4
Follow the PowerShell listing to see how the VNet and subnet are retrieved, the delegation is added, and the VNet is saved. section 4.2.2




