az-303,

How to Peer Virtual Networks in Azure

Sven Malvik Sven Malvik Connect Dec 23, 2020 · 3 mins read
How to Peer Virtual Networks in Azure

When we have two services running in two different virtual networks, they cannot communicate. To fix this, both VNet’s have to be peered. Virtual Network Peering is part of the AZ-303 exam for becoming an Azure Solution Architect.

Virtual Network Peering in AzureWatch Virtual Network Peering in Azure in preparation for the AZ-303 exam

Virtual network peering is also possible across subscriptions and tenants. In this post I will focus on VNet’s that are in the same subscription as this is part of the AZ-303 exam.

Use case

I provisioned two virtual networks with two subnets and two virtual machines of type Windows Server 2016 Datacenter. Both VMs have only a private IP address. The one VM vm2 has the Internet Information Service (IIS) up and running. When we now would login to vm1, and try to send a request to vm2 on port 80, we will get disappointed. vm1 doesn’t know about the other network. We’ll try this out in a minute.

vm1 sends request to another network to vm2vm1 sends request to another network to vm2

What we need to do is to peer both virtual networks witch each other. In this case we can do this easily, and I will show you soon how. We can peer the networks because they have different IP address ranges and don’t overlap. That’s very important. Virtual network peering is only possible when the IP address ranges don’t overlap.

Diagram of VNet peeringDiagram of VNet peering

Let’s now set the scene first.

Preparation

I have already created two virtual networks with two subnets and two virtual machines of type Windows Server 2016 Datacenter as shown in the resource overview.

Resource overviewResource overview

I want to show you first that both networks don’t know about each other at this point. We take a look at the IP address of vm2 where the IIS is running, so we can test it from vm1.

Virtual machine overviewVirtual machine overview

I login to vm1 and try the private IP address of vm2 in a browser. The result we get back is NOTHING as vm1 doesn’t know the other address.

Try accessing VM from another network failedTry accessing VM from another network failed

Peering

To peer virtual networks, click on one of them …

VNet overviewVNet overview

… and select Peerings

VNet peeringVNet peering

Click on Add to configure and create a peering between two Azure virtual networks.

Add Azure virtual networksAdd Azure virtual networks

Peering of two networks has two sides that we will name. I named the side where vm1 is as 1and2, stupid name I know - it’s just a name for the purpose of this demo :)

Naming one side of VNet peeringNaming one side of VNet peering

We scroll down a bit and name the other side 2and1, and set the other virtual network to vnet2. After clicking Create Azure will create resources in both virtual networks.

Setting the other side of Vet peeringSetting the other side of Vet peering

As we can see is vnet1 now connected to vnet2.

VNet peering overview of vnet1VNet peering overview of vnet1

Taking a look on the other side as well we see that vnet2 is connected to vnet1.

VNet peering overview of vnet2VNet peering overview of vnet2

Test

Finally, we can repeat the test from the beginning by sending a request from vm1 to vm2 where the IIS is running.

Accessing VM from another network succeededAccessing VM from another network succeeded

Join Newsletter
Get the latest updates right in your inbox. I never spam!
Sven Malvik
Written by Sven Malvik

Latest Stories

How To Manage Azure Virtual Machines

I will go through the first steps for managing Virtual Machines. We will create a Windows VM, start the Internet Information Service IIS,...

Dec 26, 2020

How to Use Azure Bastion as a Jump Host

Knowing about Azure Bastion is part of the AZ-303 exam for becoming an Azure Solution Architect. Bastion is very useful in cases where yo...

Dec 20, 2020

How to Establish a VPN Point to Site Connection in Azure

I will demonstrate how to establish a point to site connection in Azure, and connect from a Windows workstation to a virtual machine via ...

Dec 17, 2020

How to Create Custom Routes in Azure

Custom Routes, or user defined routing, is part of the az-303 certification for becoming an Azure Solution Architect. In this video I tel...

Dec 24, 2020

How to configure Azure Storage Accounts to Allow Access from Specific Subnets

Sometimes we store items in a storage account and want to restrict the access to certain services or clients. I will demonstrate how to r...

Dec 25, 2020

How to do a Failover of a Windows Server VM with Azure Site Recovery

In this post I will create a Windows Server 2016 Datacenter and then do an automatic failover to another region with Azure Site Recovery....

Jan 04, 2021

Event-Driven Infrastructure with App Configuration

Azure App Configuration is great for externalizing application configurations. But what if an application is our infrastructure? How coul...

Sep 12, 2020

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

Microsoft updated it’s role based exam for AZ-300. It’s now called AZ-303 and launched last year. This certification is a great proof for...

Feb 01, 2021

How to Recover a Virtual Machine with Azure Backup Service

This episode is about the Azure Backup Service, and how we can restore a virtual machine. I have already a Windows Server 2016 Datacenter...

Dec 29, 2020

How is Azure Firewall different from Network Security Groups?

Azure provides two security features in Azure for managing inbound and outbound traffic to and from Azure resources like virtual machines...

Feb 04, 2021

Serving Website Images from Azure CDN with SSL

In this post I will show you step by step how to serve images on a website from Azure CDN with SSL enabled. My blog has a couple of Azure...

Apr 25, 2020

Latest Stories

How To Manage Azure Virtual Machines

How To Manage Azure Virtual Machines

I will go through the first steps for managing Virtual Machines. We will create a Windows VM, start the Internet Information Service IIS,...

Dec 26, 2020

How to Use Azure Bastion as a Jump Host

How to Use Azure Bastion as a Jump Host

Knowing about Azure Bastion is part of the AZ-303 exam for becoming an Azure Solution Architect. Bastion is very useful in cases where yo...

Dec 20, 2020

How to Establish a VPN Point to Site Connection in Azure

How to Establish a VPN Point to Site Connection in Azure

I will demonstrate how to establish a point to site connection in Azure, and connect from a Windows workstation to a virtual machine via ...

Dec 17, 2020

How to Create Custom Routes in Azure

How to Create Custom Routes in Azure

Custom Routes, or user defined routing, is part of the az-303 certification for becoming an Azure Solution Architect. In this video I tel...

Dec 24, 2020

How to configure Azure Storage Accounts to Allow Access from Specific Subnets

How to configure Azure Storage Accounts to Allow Access from Specific Subnets

Sometimes we store items in a storage account and want to restrict the access to certain services or clients. I will demonstrate how to r...

Dec 25, 2020

How to do a Failover of a Windows Server VM with Azure Site Recovery

How to do a Failover of a Windows Server VM with Azure Site Recovery

In this post I will create a Windows Server 2016 Datacenter and then do an automatic failover to another region with Azure Site Recovery....

Jan 04, 2021

Event-Driven Infrastructure with App Configuration

Event-Driven Infrastructure with App Configuration

Azure App Configuration is great for externalizing application configurations. But what if an application is our infrastructure? How coul...

Sep 12, 2020

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

AZ-303 Self-Study Guide for Becoming an Azure Solution Architect

Microsoft updated it’s role based exam for AZ-300. It’s now called AZ-303 and launched last year. This certification is a great proof for...

Feb 01, 2021

How to Recover a Virtual Machine with Azure Backup Service

How to Recover a Virtual Machine with Azure Backup Service

This episode is about the Azure Backup Service, and how we can restore a virtual machine. I have already a Windows Server 2016 Datacenter...

Dec 29, 2020

How is Azure Firewall different from Network Security Groups?

How is Azure Firewall different from Network Security Groups?

Azure provides two security features in Azure for managing inbound and outbound traffic to and from Azure resources like virtual machines...

Feb 04, 2021

Serving Website Images from Azure CDN with SSL

Serving Website Images from Azure CDN with SSL

In this post I will show you step by step how to serve images on a website from Azure CDN with SSL enabled. My blog has a couple of Azure...

Apr 25, 2020