Create Virtual Networks

This article guides you through the process of creating a virtual network (VNet) in Azure, a fundamental building block for your cloud deployments.

Prerequisites

Before you begin, ensure you have:

Steps to Create a Virtual Network

Method 1: Using the Azure Portal

The Azure portal provides a user-friendly graphical interface for creating VNets.

  1. Sign in to the Azure portal.
  2. In the search bar at the top, type "Virtual networks" and select it from the results.
  3. Click "Create virtual network".
  4. On the "Basics" tab:
    • Subscription: Select your Azure subscription.
    • Resource group: Choose an existing resource group or create a new one.
    • Name: Enter a unique name for your virtual network (e.g., MyVNet).
    • Region: Select the Azure region where you want to deploy your VNet.
  5. On the "IP Addresses" tab:
    • IPv4 address space: Define the address space for your VNet. You can add multiple CIDR blocks (e.g., 10.0.0.0/16).
    • Subnets: Create at least one subnet. Define a name (e.g., default) and an address range within the VNet's address space (e.g., 10.0.1.0/24).
  6. Configure additional settings like Security, Tags, and Review + create as needed.
  7. Click "Create" to deploy your virtual network.

Method 2: Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for automating Azure resource management.

First, ensure you have the Azure CLI installed and are logged in to your account:

az login

Then, use the following commands to create a VNet:


# Set your subscription context (if you have multiple)
# az account set --subscription "Your Subscription Name"

# Create a resource group if you don't have one
az group create --name MyResourceGroup --location eastus

# Create a virtual network with a subnet
az network vnet create \
    --resource-group MyResourceGroup \
    --name MyVNet \
    --address-prefix 10.0.0.0/16 \
    --subnet-name default \
    --subnet-prefix 10.0.1.0/24
        

Method 3: Using Azure PowerShell

Azure PowerShell provides another scripting option for VNet creation.

Connect to your Azure account:


Connect-AzAccount
        

Create a VNet using the following script:


# Define variables
$resourceGroupName = "MyResourceGroup"
$vnetName = "MyVNet"
$location = "eastus"
$vnetAddressPrefix = "10.0.0.0/16"
$subnetName = "default"
$subnetPrefix = "10.0.1.0/24"

# Create a resource group if it doesn't exist
New-AzResourceGroup -Name $resourceGroupName -Location $location -ErrorAction SilentlyContinue

# Define the subnet configuration
$subnetConfig = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix $subnetPrefix

# Create the virtual network
New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroupName -Location $location -AddressPrefix $vnetAddressPrefix -Subnet $subnetConfig
        

Next Steps

Once your virtual network is created, you can:

Important: Carefully plan your IP address space and subnet allocation to avoid conflicts and ensure scalability for future growth.
Deploy Now