How to deploy a hub virtual network in Azure.
Tags: azure, virtualnetwork, segmentation, peering
Published: 2024-07-11 21:53:32

---
title: How to deploy a hub virtual network in Azure.
published: true
description: How to create a Virtual network in Microsoft azure.
tags: Azure, VirtualNetwork, segmentation, Peering
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54l2u8cgscei3wfpyxzi.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-07-10 02:44 +0000
---
# Introduction 
This article provides steps for how to create an Azure-based hub virtual network (VNet) with subnets and address space from scratch, as well as how to configure a virtual network peering. This is to allow for the virtual networks to communicate with each other securely and privately.

# Scenario
A hypothetical Web Application requires network isolation and segmentation in a network for secure and private communication. The virtual networks and subnets will be created in the following steps.

## Step 1: Create hub and spoke virtual networks and subnets

### I. Creating the virtual networks 
- Open a browser and navigate to the Azure portal and login.
- To create a Virtual Network, click the hamburger icon at the top left 
  hand side corner of the portal.
![Click hamburger icon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd3q632vse9boxl6cn2a.png)
- In the displayed pane, select **Virtual Networks**.
![Select virtual network from the sidebar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08sijueyvntj7yr1xr4k.png)
- In the “Virtual Networks” portal pane, select **+ Create**.
![Select Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1jkxpl1jo35hfknm8gj.png)
- At the **Resource group label** select "create new" to create a new 
  resource group. Give the resource group a name and click **Ok**. Keep in 
  mind that this is the "parent directory" for the virtual networks to be 
  created.
![Create Resource group](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5uxbprj3x85thslfbdnu.png)
![Click Ok](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ai5lww2lfdgvsq223p9b.png)
- Also, give a name to the virtual network at the "virtual network name" 
  label.
![Virtual network name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6y58gb6ts0bpgoxueoc.png)
- Select a Region from the dropdown list at the **Region** label. In this 
  case, I selected **East US**.
![Select Region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/349ddqnpag81rv0455dt.png)
- Next, Select the **IP Addresses** tab at the top of the page.
![Select IP addresses tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i07lmjwgg5bpjqthcd09.png)

### II. Create subnets for the first Virtual Network.
- At the dropdown menu displayed above the **address space** box on the 
  displayed page, check that the dropdown is set to **Add IPv4 address 
  space**
![Add IPv4 address space](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54g5ytg3iiuhdxmobb69.png)
- In the address space box, change **Subnet address range** to **10.1.0.0/16** (This is usually the default IP address so you may not need to change it in this instance). 
- locate a pen icon at the bottom corner, in the address space box (next 
  to the garbage can icon). Click on this icon to edit the default **Subnet** name.
![The address space box](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2igfkx8wmlky16zkt4zl.png)
- Change **Subnet** name to **frontend**
- Also, change **Subnet address range** to **10.1.0.0/24** using the 
  **size** label. Leave all other settings as their defaults.
- Click **Add** to close the **Edit Subnet** pane. This 
  completes the creation of the first Subnet. 
![Edit Subnet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeg4ikzzqd0cuxqpaki9.png)

- The next step is to create the second subnet. As you can see, the 
  **frontend** subnet is listed in the box. We need to create another 
  subnet in this virtual network. Again, locate the pen 
  icon at the bottom (next to the garbage can icon). Click on this icon to 
  add another **Subnet**.
![create second subnet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0s1dfimph8pnkdq7wn1.png)

- Also, change the **subnet** name to **backend**, then change the 
  **Subnet address range** to **10.1.0.0/24**.
![second subnet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qrjgmz9l3pm9tyw706wq.png)
- Again, leave all other settings as their defaults. Click **Add** to close the **edit subnet** pane. 
- Select **Review + Create** to validate the configurations and **Create** to create the first virtual network.

![Review + Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aemb7rzmxa7lnt8ktr9z.png)
![Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5gqfrcziacljzcupu36.png)
![Deployment in progress](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pfrkzqcpavu5il8qi6n.png)
![Deployment completed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swe46v0s4xj5kpt14id4.png)

### III. Creating the second virtual networks 
- Creating the second virtual network is similar to creating the first 
  virtual network.
- click the hamburger icon at the top left-hand side corner of the Azure 
  portal.
- Again, in the displayed pane, select “Virtual Networks”.
- In the “Virtual Networks” portal pane, select “+ Create”.
- At the Resource group label select from the drop-down menu the first 
  Resource group that was created.
- Also, give a name to the virtual network at the "virtual network name" 
  label. Here the name I supplied was **Hub-vnet**.
- Select a similar Region from the dropdown like the first virtual network 
  list at the Region label. In the previous virtual network, I selected 
  **East US**.
![Resource group & network name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9whh672h6g5xl2yew9g.png)
- Next, Select the **IP Addresses** tab at the top of the page.
- set the **IPv4 address space** to **10.1.0.0/16**

### IV. Create a subnet for the second Virtual Network.
- In the address space box, locate a pen icon at the bottom (next to the 
  garbage can 
  icon). 
- Click on this icon to edit the default **Subnet** name.
- At the flyout pane, change **subnet purpose** to **Azure Firewall** from 
  the **Default** settings. 
![subnet purpose](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi8snzp3kiyr9zj5fxi7.png)

- Change Subnet **name** label to **AzureFirewallSubnet**
![subnet name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b56fj9idd1mwl7pccqt1.png)
- Also, change **Subnet address range** to **10.1.0.0/26**.
![starting address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pvcpqqzgp8bxu2x80p8s.png)
- Leave all other settings as their defaults.
- select the **save** button to Close the **edit Subnet** pane. This 
  completes the creation of the Subnet for the second virtual network.
 ![Select Save](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iagivj18qssxutlqz3e9.png)
- Select **Review + Create** to validate the settings.
![Review + Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/val7r5tcsipcmdc9zqou.png)
- After validation is complete select the **Create** button to create the 
  second virtual network and watch the process complete deployment.
![Create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vm81rxw75uci4zdutstr.png)
![deployment in progress](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgls785mfpjs39seyxhv.png)
![deployment complete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40a6ojjli4hilxj5qv15.png)

## Step 2: Setup a peer relationship between the virtual networks
- Once the deployment is complete for the second virtual network, navigate 
  back to the portal. In the search bar type **resource groups** and 
  select **Resource Groups** from the results. 
- Select the required **Resource group** in the main pane and confirm that 
  both virtual networks have been deployed.
![The virtual networks](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dxsm8mh3nh232758y8ob.png)
- Setting up a peer relationship between the two virtual networks aims to  
  allow traffic to flow in both directions between the **app-vnet** and 
  **hub-vnet** virtual networks.
- In the Portal and the resource group view, Select the first virtual 
  network created from the table. In my case it was the **app-vnet** 
  virtual network.
![app-vnet virtual network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukav9keo90l3qehoz2u5.png)
- On the **app-vnet** overview page select **settings** the left-hand 
  sidebar of the portal.
![settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duv4zyq1v1tmls4ior3f.png)
- Scroll down and select **peerings** to add peering.
![peerings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfjsm15e1ekqz1ytk367.png)
- In the **app-vnet** peerings pane, Select **+ Add**. 
![+ Add](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdlkolsfg4ac1a9ouhak.png)
- Fill out under the **Remote virtual network summary** heading supply a 
  name for **Peering link name** with **app-vnet-to-hub**.
![Peering link name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpftykjagjy9ibilysdo.png).

- Select the first virtual network from the drop-down.
![hub-vnet virtual network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/477yi3t4fxeoso0ss5x2.png)
- Scroll the page down to the **Local virtual network summary** heading. 
  Fill out the **Peering link name** with **hub-to-app-vnet**.
![hub-to-app-vnet Peering link name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v7v9teuevs7e20tb6iue.png)
- Leave all other settings as their defaults. Select **Add** to create the 
  virtual network peering.
![Add peering button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xue2boz40lpkh9lz3bns.png)
- You should see a notification at the top right of the page that says 
  **Adding virtual network peering**
![Adding virtual network peering](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6lgqrpbp24i8b2jmljx.png)
- Once the process completes, and after the configuration updates, 
  this validates that the Peering status is set to **Connected**. 
  (you may have to refresh the page to see the updated status)
  
![Perring status is connected](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4almsndpk5gei9qz1qb1.png)
![Deployment succeded](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ic28jnlxrvujc175e1em.png)

# Conclusion.
This article explains how to provide network isolation and segmentation for a web application, in an Azure virtual network with subnets with address space. We have learned the following:
- Creating virtual networks
- Creating subnets within the virtual networks, and
- Configuring virtual networking peering which means allowing two or more 
  virtual networks to connect and appear as one for connectivity purposes.
  
It's been great sharing my journey into cloud engineering and I hope to see you soon on the other articles.


Cover Image by <a href="https://unsplash.com/@alinnnaaaa?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Alina Grubnyak</a> on <a href="https://unsplash.com/photos/low-angle-photography-of-metal-structure-ZiQkhI7417A?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>