Using Azure Network Manager to manage your Hub&Spoke network topology

Most Azure services need us to deploy a network environment to locate and manage these services when we use Azure. 

The most representative network topology in Azure is the Hub&Spoke network topology.

Putting the management resources like the VPN gateway, Azure firewall, or Bastion into the Hub virtual network. The resources that belong to systems will be located in the virtual networks called the Spoke virtual network.

This topology actually helps users manage the network more easily. I love this topology too.

---
But here is the thing. 

The dull point is that you need to deploy a **Network Peering** between two virtual networks to let them communicate with each other.

As the diagram below shows, to deploy a network environment with one Hub virtual network and three Spoke virtual networks, three Network Peerings are necessary.
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/b21445e5-10ee-eecf-5be9-4e9a276d279a.png)
|:-:|


But, in some cases, clients need to connect Spoke virtual networks to each other. Then, the increase of the Network Peering will be exponential.

Think about the necessary number of Network Peering under the conditions below.
(In the case that Spoke virtual networks need to connect with each other)

・**6** Network Peerings are needed for 1 Hub virtual network and 3 Spoke virtual networks.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/74f49896-0fe2-19f3-e6c1-784fecc35116.png)

・**15** Network Peerings are needed for 1 Hub virtual network and 5 Spoke virtual networks.

・**36** Network Peerings are needed for 1 Hub virtual network and 8 Spoke virtual networks.

The necessary number of Network Peering can be calculated following the formula: 
**n×(n-1)/2**
※n=the number of virtual networks you want to connect with.(including the hub virtual network)

So manually managing the Network Peering could be chaos, depending on the number.  

And once you missed the setting of a Network Peering, then you screwed up.

---

Okay, let's start talking about the solution.

Here is the solution: Azure Virtual Network Manager.

https://learn.microsoft.com/en-us/azure/virtual-network-manager/overview


Azure Virtual Network Manager is a management service that enables you to group, configure, deploy, and manage virtual networks globally across subscriptions.

Simply put. 
**Virtual Network Manager helps users manage their virtual networks more efficiently.**

The most significant advantage of using this service is that it can deploy Network Peering automatically, and users only need to group Spoke virtual networks and tell which virtual network is the Hub.

Next, let us try to **deploy a Virtual Network Manager** and use it to **create a Hub and Spoke network topology environment**.

---
### Network Diagram
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/d063fe2c-f4ac-c41d-5a11-bdc97f1bf019.png)
|:-:|

We have a total of five virtual networks in the subscription and one of them will be the Hub virtual network and the other four will be the Spoke virtual networks.

■ Hub virtual network
self-s2s-hub-vnet

■ Spoke virtual network
1.self-s2s-spoke01-vnet
2.self-s2s-spoke02-vnet
3.self-s2s-spoke03-azuremigration
4.self-s2s-spoke04-private-VNET


#### We will do the following operations.
1. Deploy a Virtual Network Manager
1. Create two virtual network groups
1. Create a Hub and Spoke connectivity rule for the two virtual network groups<br> ※ Allow the Spoke virtual networks in one network group to connect with each other.
1. Assign the connectivity rule to the Japan Eash Region to enable it
1. Confirm the network peerings

---

### <font color="Navy">Step.1<br> Deploy a Virtual Network Manager</font>
##### 1. Open the **[Network managers]** in the Azure Portal

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/ef9de3f7-c075-1873-4e92-389c9af6ccd7.png)
|:-:|

##### 2. Click [Create]

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/c1ed9aa9-1c27-6406-d367-d3bf1dc4117c.png)
|:-:|

##### 3. Tab [Basic]
Virtual Network Manager needs a resource group to store its information. 
Personally, I prefer to choose the hub virtual network's resource group.<br>
Select ”connectivity” in the [Feature] section.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/0cf8aa40-a2ca-b63d-91ea-7fa1ed3e97eb.png)
|:-:|

##### 4. Tab [Managerment scope]
Click [Add] to add a new management scope.
Virtual Network Manager can be assigned to a management group or a subscription.

This time, we assign the manager to the subscription scale.

***<font color="Red">Note: Remember that multiple virtual network managers cannot overlap on one selected scope. For example, two Azure Virtual Network Managers can’t manage security for the same management group.</font>***


|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/44a58e08-3e14-8965-ac81-2d909b743335.png)
|:-:|

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/b7262e0a-ba52-8e43-30a0-23c669b0f920.png)
|:-:|

##### 5. Review and create
Set up the Tags if you need them, but we will skip it this time.
Click [Create] to start deploying after you confirm the information.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/14d24da6-d90f-0f0c-6703-0afe62dc7bde.png)
|:-:|

##### 6. After the deployment
We can find the resource we deployed in the list.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/deb35290-c91b-dd81-5476-2cc9d41ea3f5.png)
|:-:|

---

### <font color="Navy">Step.2<br> Create two virtual network groups</font>

After deploying the Virtual Network Manager instance, we need to create two network groups for the four Spoke virtual networks next. 

##### 1. Select [Network groups] from the blade menu on the left side and click [Create]

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/ac55f789-24df-623a-987f-b0b5a49db81f.png)
|:-:|

##### 2. Give it a name
Give the network group a name and click [Create]. That's it.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/ffbd4106-4299-483e-04f3-087c03964fe9.png)
|:-:|

And then create the other network groups.
Now, there are two network groups in the list.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/850e6c63-e67d-9bdb-6a39-61e3a36e0d02.png)
|:-:|

##### 3. Add group members
We've created two network groups.
Now, we will add Spoke virtual networks to the network groups following the structure below.

■network-group-01
- self-s2s-spoke01-vnet
- self-s2s-spoke02-vnet

■network-group-02
- self-s2s-spoke03-azuremigration
- self-s2s-spoke04-private-VNET

<font color="Red"> ***Note: Do not add the Hub virtual network to any network group.***</font>

=========

i. Click [network-group-01] and then select [Group members] from the blade menu.
Click [Add] and choose [Manually add members.]
※You can also create Azure Policies to add automatically virtual networks. 

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/98f96b64-a752-942b-5a87-ed5afbec038f.png)
|:-:|

ii. Select the virtual networks you want to add and click [Add].

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/879db9b5-6f38-7fcc-0861-46b8db976240.png)
|:-:|

iii. The virtual networks that are added to the network group can be found in the group member list.
※Sometimes, you may need to click "Refresh" to update the information on the screen.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/0e927bfb-02f1-2b49-bfba-6388b54afff6.png)
|:-:|

iv. Let's do the same thing for [network-group-02].

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/8ada8b36-2fe7-a11b-a3f8-c892c32b3c58.png)
|:-:|

---

### <font color="Navy">Step.3<br> Create a Hub&Spoke connectivity rule for the two virtual network groups</font>

We created two network groups for the four Spoke virtual networks.
The next step will be making a network connectivity rule.

##### 1. Select [Configurations] from the blade menu of the Virtual Network Manager and click [Connectivity configuration].

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/cc68a3a2-779a-845a-ee94-76f198da8371.png)
|:-:|

##### 2. [Basic] Tab
Define a name that makes you quickly understand what this resource is for.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/c0b2b119-12cb-56ee-6f9b-3a89ad6d98d7.png)
|:-:|

##### 3. [Topology] Tab

This is the main tab.
Select [Hub and Spoke] Topology and choose a virtual network as the Hub. Remember that the Hub virtual network must not belong to any Spoke network group.

If you already have network peerings between the Hub virtual network and the Spoke virtual networks and you want to keep it, then do not check the item [Delete existing peerings]. It depends on your requirements.

Finally, add the two network groups to the rule. 
(At least one network group is necessary to finish the setup.)

Check the option **[Hub as gateway]** if you need all the Spoke virtual networks to use the Gataway in the Hub virtual networks.

Check the option **[Enable connectivity within network group]** if you need virtual networks in the network group to connect with each other.

Check the option **[Enable mesh connectivity across regions]** if you need to do so.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/42b789ed-535b-f035-a6a4-b608e369140c.png)
|:-:|

##### 4. [Visualization] Tab

Connectivity within the Hub virtual network and network groups can be confirmed here.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/1a38ba86-308b-7874-f9c1-258cf0db2609.png)
|:-:|


##### 5. Review and deploy

Click [Create] after confirming the information.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/52d73e5a-af47-6576-70aa-1c1993398985.png)
|:-:|

##### 6. Confirm after deployment

We can find the deployed rule in the [Configuration] list, and the setup information about network groups can be found in the [Network groups] menu in the rule.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/bf74c8b9-8116-901b-9daa-649e5af03d9c.png)
|:-:|

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/3d8590cd-bbe2-aee2-dcf9-b7e566e51115.png)
|:-:|

---

### <font color="Navy">Step.4<br> Assign the connectivity rule to the Japan East region to enable it</font>

To enable the connectivity rule, we need to assign the rule to regions.

##### 1. Select [Deployments] from the Network Manager's blade menu and click [Connectivity configuration]

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/043b5e06-f6d3-6fec-999b-e2a91f6b73ea.png)
|:-:|

##### 2. [Goal state] Tab

Select the connectivity rule(configuration) we deployed.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/917dc38f-72d5-d1fb-498b-8ab115c27fa4.png)
|:-:|

Select the regions to which you need the connectivity rule to be assigned.
This time we only select Japan East.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/148863ef-6ac2-5c39-f467-3b19c51bd161.png)
|:-:|

##### 3. [Review + deploy] Tab

Click [Deploy] after confirming the information.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/4c4be8cf-a518-054b-a5f5-c9f1757d877d.png)
|:-:|

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/aa0baaf7-0bb0-7cc6-ad58-9e9d29f6a755.png)
|:-:|

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/9a21f393-40a2-563e-d193-dbefa739c522.png)
|:-:|

---

### <font color="Navy">Step.5<br> Confirm the network peerings</font>

These are all the operations we need to accomplish to set up a Hub and Spoke network topology within Virtual Network Manager.

In the last part of this blog, let's confirm the Network Peerings between the Hub virtual network and Spoke virtual networks.

Move to the list of Virtual Networks.

=========
###### [Hub virtual network]

The Hub virtual network should have four Network Peerings connected to each Spoke virtual network.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/bbaf5b86-dff9-44df-b9c0-698db4251ff1.png)
|:-:|

###### [self-s2s-spoke01-vnet]

This spoke virtual network has only one Network Peering connected to the Hub virtual network.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/a32f831b-1fe0-12db-86ce-481813f18bd6.png)
|:-:|

###### [self-s2s-spoke02-vnet]

This spoke virtual network also has only one Network Peering connected to the Hub virtual network.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/cbd3bd31-ed88-f383-6aab-1d295ef12cd8.png)
|:-:|

###### [self-s2s-spoke03-azuremigration]

<font color="Red">Note: We may think this spoke virtual network should have two Network Peerings that are one for the Hub virtual network and the other for the Spoke virtual network [self-s2s-spoke04-private-VNET]. But there is only one Network Peering connecting with the Hub virtual network, which can be found in the Network Peering list.<br><br>It is because the connections in a network group are not listed in the Network Peering list. But, the connections exist exactly!</font>

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/db065227-26bc-8368-e20c-cd4208ea5e52.png)
|:-:|

###### [self-s2s-spoke04-private-VNET]

This Spoke virtual network also has only one Network Peering in the list. But for the same reason as [self-s2s-spoke03-azuremigration], This virtual network can access other virtual networks in the same network group.

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/3f3fd043-4bd1-8ec4-6e88-5d8d6a25e8d7.png)
|:-:|

---

These are all for deploying a Hub and Spoke network topology within the Virtual Network Manager.  Virtual Network Manager can help you manage the Network Peerings in a Hub and Spoke topology, making it more efficient and easier.

---
#### <font color="Navy">Here is some additional information that you need to know before leaving.</font>

１. When assigning new rules(configurations) to a region that already has rules, if you want to keep the current rules, you need to select both the new rules and the current rules. If you don't do so, the current rules will be removed.

##### [assigning new rules without selecting the current rules]
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/fda7c879-109a-3274-08d8-3f2f7bd6f60d.png)
|:-:|

##### [assigning new rules within selecting the current rules]
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/031ae3f8-3cea-bfcd-94e8-52dac6ac1a76.png)
|:-:|

=========

２. The setting of "Direct connectivity," "Global mesh," and "Hub as gateway" in the category [Topology] cannot be modified once the rule(configuration) is deployed. 

So, Deploy a new rule(configuration) if you need to change the setting of the items mentioned above. 

##### You can change the settings while deploying the rule(configuration)
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/bad65c89-5ab2-2536-e208-e4178eb8fc0d.png)
|:-:|

##### The settings cannot be changed after the deployment
|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/507261df-633f-3dd8-2347-f7d8e94cedc9.png)
|:-:|

=========

３. As we have mentioned previously, remember that virtual networks in a network group with "Direct connectivity" enabled can connect with each other. 

|![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2985687/3f2cc7e0-56b5-89f2-c2a8-8106e9605622.png)
|:-:|

You cannot find the Network Peering representing the connections of these virtual networks because personally, I assume the connections are not looked at as Network Peerings but they exist exactly.


Thank you very much for reading the entire article.

See you next time!

Have a nice day!