DEV Community

Cover image for How to Create a virtual network in Azure.
EMMANUEL
EMMANUEL

Posted on

How to Create a virtual network in Azure.

A Virtual Network (VNet) is a logically isolated network(a network segment intentionally separated from other networks, including the public internet, to improve security and performance by containing threats and controlling traffic flow)in the cloud that lets you securely connect and manage your resources, just like a traditional on-premises network.

Azure Virtual Network provides the fundamental building block for your private network in Azure. This service enables Azure resources like virtual machines (VMs) to securely communicate with each other, the internet, and on-premises networks. Virtual networks deliver the scale, availability, and isolation benefits of Azure infrastructure while maintaining the familiar networking concepts you use in traditional datacenters.

Virtual network

In this article, lets create two virtual networks app-vnet and hub-vnet that simulates a hub and spoke network architecture. The app-vnet will host the application. This virtual network requires two subnets. The frontend subnet will host the web servers. The backend subnet will host the database servers. The hub-vnet only requires a subnet for the firewall. The two virtual networks must be able to communicate with each other securely and privately through virtual network peering. Both virtual networks should be in the same region.

Architecture diagram

The Microsoft provides multiple ways to create Azure Virtual Networks.

  • Using the Azure Portal
  • Using Azure PowerShell
  • Using the Azure CLI

This tutorial covers using the Azure portal.

Create hub and spoke virtual networks and subnets

1.Login to your Azure portal. https://portal.azure.com

Azure Login

2.In the search Resources, search for virtual network,click enter and select the grayed out virtual machine.

Azure search Resource

3.Select + Create

+ Create virtual network

4.Complete the configuration of the app-vnet.

  • Resource group RG1
  • Virtual network name app-vnet
  • Region East US

Configuration of app vnet

5.Still on the configuration of the app vnet, This virtual network requires two subnets, frontend and backend.

  • IPv4 address space(vnet IP address) 10.1.0.0/16

Virtual network IP address

  • Subnet name frontend
  • Subnet address range 10.1.0.0/24

Frontend subnet

  • Subnet name backend
  • Subnet address range 10.1.1.0/24

Backend subnet:

6.Leave all other settings as their defaults. When finished select “Review + create and wait for the validation to pass

Review + create
Select Create
Create

Create the Hub-vnet virtual network configuration. This virtual network has the firewall subnet

1.In your Azure portal, , search for virtual network and select the grayed virtual nerwork.

virtual network

2.Select + Create

+ Create

3.Configure the Hub-vnet virtual network. This virtual network has firewall subnet .

  • Resource group RG1
  • Name hub-vnet
  • Region East US

Hub vnet

  • IPv4 address space 10.0.0.0/16

IPv4 address space

  • Subnet name AzureFirewallSubnet
  • Subnet address range 10.0.0.0/26

AzurefirewallSubnet

4.Select Review + Create.After validation is passed select Create

Review + Create

Deployment
Create

5.Once the deployments are complete, search for and select your ‘virtual networks`

Virtual network

6.Verify your virtual networks and subnets were deployed.

Virtual network

App-vnet Subnets

Frontend and backend

Hub-vnet firewall subnet

Firewall subnet

Configure a peer relationship between the virtual networks
Virtual network peering enables you to seamlessly connect two or more Virtual Networks in Azure.

1.Search for and select the app-vnet virtual network.

App-vnet

2.In the Settings blade, select Peerings.

Peering

3.Select + Add a peering between the two virtual networks.

+Add

4.Configure a peer relationship between the virtual networks

  • Remote peering link name app-vnet-to-hub
  • Virtual network hub-vnet

Peering

  • Local virtual network peering link name hub-to-app-vnet

Peering

5.Leave all other settings as their defaults. Select “Add” to create the virtual network peering.

Add

6.Once the deployment completes, verify the Peering status is Connected

Peering status

Top comments (0)