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.

Subnets allow you to segment your virtual network into smaller address spaces, enhancing security and manageability.

Prerequisites

Steps to Create a Subnet

1

Sign in to the Azure portal

Open your web browser and navigate to https://portal.azure.com/. Sign in with your Azure account credentials.

2

Navigate to Virtual Networks

In the Azure portal, search for "Virtual Networks" in the top search bar and select it from the services list.

Search for Virtual Networks
3

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.

Select Virtual Network
4

Access Subnets

In the left-hand menu of your virtual network, under "Settings", click on "Subnets".

Virtual Network Subnets Menu
5

Add a Subnet

Click the "+ Subnet" button at the top of the Subnets list.

Add Subnet Button
6

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.
Subnet Details Pane
7

Save the Subnet

Once you have configured the details, click the "Save" button at the bottom of the pane.

Save Subnet Button

Your new subnet will now appear in the list of subnets for your virtual network.

Important:

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

# 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