VNet Peering allows two VNets in the same region to connect with each other without having to set up the VPN Gateways.
Prior to VNet Peering, we used to go with VNet to VNet connection. It didn’t matter if the VNets were in the same region or different regions.
But now, if the VNets are in the same region, we can connect them using VNet peering.
VNet to VNet connection is essentially a site-to-site connection so we need to create Virtual Network Gateways on both the VNets. But Virtual Network Gateways cost a lot of money.
VNet peering was introduced to remove the need for Virtual Network Gateways. So we can connect to VNet together without the VPN gateways. It saves a lot of money. The disadvantage to this is that the VNets need to be in the same region. It won’t work cross-regionally.
Suppose you have two different subscriptions and you have two virtual networks, one in each subscription and you want to connect them, you can do that. The only necessary thing is that they both should be in the same region.
Peering just works bi-directionally. So if you peer a VNet A with VNet B and peer VNet B with VNet C, then VNet A cannot communicate with VNet C.
So let us first create two virtual networks in the same region.
Step 1. Create a virtual network KTVNet 1 and put it into a new resource group. Put in the West India location. Click on Create.
Step 2. Create one more virtual network name KTVNet2 and put it under the same resource group and same location; i.e., West India.
Step 3. Go to KTVNet1 and go to peerings. Click on Add.
Step 4. Give a name to the peering. Select resource manager. If you don’t know the virtual machine or the subscription, you can select the resource ID. Then choose the virtual network. And keep the virtual network access as enabled.
Step 5. Allow forward traffic allows the traffic of peered VNet into this VNet. Allow gateway transit allows the peered VNet to use this VNet’s gateway (if any), but for that, "use remote gateways" must be enabled in the peered VNet. Click on OK.
Step 6. The peering will be listed and the status will be shown as initiated. Now we need to add a peering to KTVNet2 as well.
Step 7. Add a peering to the KTVNet2 as shown below. And keep forwarded traffic, gateway transit, and remote gateways as unchecked because we do not have any gateway in any of the VNets. Click on OK.
Step 8. It can be seen in both the VNets that the connection is established.
Hence we can say that we have established a successful VNet peering.