Create a Subnet in an Azure Virtual Network
This guide walks you through the process of creating a subnet within an existing Azure Virtual Network (VNet) using the Azure portal.
Prerequisites
- An existing Azure Virtual Network. If you don't have one, please create it first.
- Permissions to create and manage resources within your Azure subscription.
Steps to Create a Subnet
Sign in to the Azure portal
Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.
Navigate to Virtual Networks
In the Azure portal, search for "Virtual Networks" in the top search bar and select it from the services list.
Select your Virtual Network
On the Virtual Networks page, select the virtual network you want to add a subnet to. This will open the virtual network's overview page.
Access Subnets
In the left-hand menu of your virtual network, under "Settings", click on "Subnets".
Add a Subnet
Click the "+ Subnet" button at the top of the Subnets list.
Configure Subnet Details
A pane will appear on the right. Fill in the following details:
- Name: A unique name for your subnet (e.g., `myAppSubnet`, `backendSubnet`).
- Address range: A valid, non-overlapping IPv4 CIDR block within your virtual network's address space. For example, if your VNet is `10.0.0.0/16`, you could use `10.0.1.0/24`.
- Network security group: (Optional) Select an existing Network Security Group (NSG) or create a new one to control traffic to and from the subnet.
- Route table: (Optional) Select an existing route table or create a new one for custom routing.
- Service endpoints: (Optional) Choose Azure services for which you want to enable service endpoints for this subnet.
- Private endpoint network policies: (Optional) Enable or disable network policies for private endpoints.
- NAT gateway: (Optional) Associate a NAT gateway with the subnet for outbound connectivity.
Save the Subnet
Once you have configured the details, click the "Save" button at the bottom of the pane.
Your new subnet will now appear in the list of subnets for your virtual network.
Ensure that the address range you define for the subnet does not overlap with other subnets in the same virtual network or with other VNets if you plan to peer them.
Next Steps
- Deploy a Virtual Machine into the subnet.
- Configure VNet peering if you need to connect this VNet to another.
- Configure Network Security Groups to control traffic.
# Example using Azure CLI to create a subnet
az network vnet subnet create --resource-group MyResourceGroup --vnet-name MyVNet --name myAppSubnet --address-prefixes 10.0.1.0/24