You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-network/tutorial-connect-virtual-networks.md
+31-31Lines changed: 31 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: In this tutorial, you learn how to connect virtual networks with vi
4
4
author: asudbring
5
5
ms.service: azure-virtual-network
6
6
ms.topic: tutorial
7
-
ms.date: 11/14/2024
7
+
ms.date: 07/11/2025
8
8
ms.author: allensu
9
9
ms.custom:
10
10
- template-tutorial
@@ -20,17 +20,17 @@ ai-usage: ai-assisted
20
20
21
21
# Tutorial: Connect virtual networks with virtual network peering
22
22
23
-
You can connect virtual networks to each other with virtual network peering. These virtual networks can be in the same region or different regions (also known as global virtual network peering). Once virtual networks are peered, resources in both virtual networks can communicate with each other over a low-latency, high-bandwidth connection using Microsoft backbone network.
23
+
You can connect virtual networks to each other with virtual network peering. These virtual networks can be in the same region or different regions (also known as global virtual network peering). Once virtual networks are peered, resources in both virtual networks can communicate with each other over a low-latency, high-bandwidth connection using the Microsoft backbone network.
24
24
25
25
:::image type="content" source="./media/tutorial-connect-virtual-networks-portal/resources-diagram.png" alt-text="Diagram of Azure resources created in tutorial." lightbox="./media/tutorial-connect-virtual-networks-portal/resources-diagram.png":::
26
26
27
27
In this tutorial, you learn how to:
28
28
29
29
> [!div class="checklist"]
30
30
> * Create virtual networks
31
-
> * Connect two virtual networks with a virtual network peering
31
+
> * Connect two virtual networks with virtual network peering
32
32
> * Deploy a virtual machine (VM) into each virtual network
33
-
> * Communicate between VMs
33
+
> * Communicate between virtual machines
34
34
35
35
## Prerequisites
36
36
@@ -63,7 +63,7 @@ If you choose to install and use PowerShell locally, this article requires the A
63
63
Repeat the previous steps to create a second virtual network with the following values:
64
64
65
65
>[!NOTE]
66
-
>The second virtual network can be in the same region as the first virtual network or in a different region. You can skip the **Security** tab and the Bastion deployment for the second virtual network. After the network peer, you can connect to both virtual machines with the same Bastion deployment.
66
+
>The second virtual network can be in the same region as the first virtual network or in a different region. You can skip the **Security** tab and the Bastion deployment for the second virtual network. After the virtual network peering is established, you can connect to both virtual machines with the same Bastion deployment.
67
67
68
68
| Setting | Value |
69
69
| --- | --- |
@@ -75,7 +75,7 @@ Repeat the previous steps to create a second virtual network with the following
75
75
76
76
### [PowerShell](#tab/powershell)
77
77
78
-
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). The following example creates a resource group named **test-rg** in the **eastus** location.
78
+
Before creating a virtual network, you must create a resource group for the virtual network and all other resources created in this article. Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). The following example creates a resource group named **test-rg** in the **eastus** location.
Create a second virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). The following example creates a virtual network named **vnet-2** with the address prefix **10.1.0.0/16**.
160
160
161
161
>[!NOTE]
162
-
>The second virtual network can be in the same region as the first virtual network or in a different region. You don't need a Bastion deployment for the second virtual network. After the network peer, you can connect to both virtual machines with the same Bastion deployment.
162
+
>The second virtual network can be in the same region as the first virtual network or in a different region. You don't need a Bastion deployment for the second virtual network. After the virtual network peering is established, you can connect to both virtual machines with the same Bastion deployment.
Before creating a virtual network, you have to create a resource group for the virtual network, and all other resources created in this article. Create a resource group with [az group create](/cli/azure/group). The following example creates a resource group named **test-rg** in the **eastus** location.
193
+
Before creating a virtual network, you must create a resource group for the virtual network and all other resources created in this article. Create a resource group with [az group create](/cli/azure/group). The following example creates a resource group named **test-rg** in the **eastus** location.
194
194
195
195
```azurecli-interactive
196
196
az group create \
@@ -250,7 +250,7 @@ az network bastion create \
250
250
Create a second virtual network with [az network vnet create](/cli/azure/network/vnet#az-network-vnet-create). The following example creates a virtual network named **vnet-2** with the address prefix **10.1.0.0/16**.
251
251
252
252
>[!NOTE]
253
-
>The second virtual network can be in the same region as the first virtual network or in a different region. You don't need a Bastion deployment for the second virtual network. After the network peer, you can connect to both virtual machines with the same Bastion deployment.
253
+
>The second virtual network can be in the same region as the first virtual network or in a different region. You don't need a Bastion deployment for the second virtual network. After the virtual network peering is established, you can connect to both virtual machines with the same Bastion deployment.
254
254
255
255
```azurecli-interactive
256
256
az network vnet create \
@@ -284,7 +284,7 @@ $peerConfig1 = @{
284
284
Add-AzVirtualNetworkPeering @peerConfig1
285
285
```
286
286
287
-
In the output returned after the previous command executes, you see that the **PeeringState** is **Initiated**. The peering remains in the **Initiated** state until you create the peering from **vnet-2** to **vnet-1**. Create a peering from **vnet-2** to **vnet-1**.
287
+
In the output returned after the previous command executes, you see the **PeeringState** is **Initiated**. The peering remains in the **Initiated** state until you create the peering from **vnet-2** to **vnet-1**. Create a peering from **vnet-2** to **vnet-1**.
288
288
289
289
```azurepowershell-interactive
290
290
$peerConfig2 = @{
@@ -295,7 +295,7 @@ $peerConfig2 = @{
295
295
Add-AzVirtualNetworkPeering @peerConfig2
296
296
```
297
297
298
-
In the output returned after the previous command executes, you see that the **PeeringState** is **Connected**. Azure also changed the peering state of the **vnet-1-to-vnet-2** peering to **Connected**. Confirm that the peering state for the **vnet-1-to-vnet-2** peering changed to **Connected** with [Get-AzVirtualNetworkPeering](/powershell/module/az.network/get-azvirtualnetworkpeering).
298
+
In the output returned after the previous command executes, you see the **PeeringState** is **Connected**. Azure also changed the peering state of the **vnet-1-to-vnet-2** peering to **Connected**. Confirm the peering state for the **vnet-1-to-vnet-2** peering changed to **Connected** with [Get-AzVirtualNetworkPeering](/powershell/module/az.network/get-azvirtualnetworkpeering).
299
299
300
300
```azurepowershell-interactive
301
301
$peeringState = @{
@@ -311,7 +311,7 @@ Resources in one virtual network can't communicate with resources in the other v
311
311
312
312
## Peer virtual networks
313
313
314
-
Peerings are established between virtual network IDs. Obtain the ID of each virtual network with [az network vnet show](/cli/azure/network/vnet#az-network-vnet-show) and store the ID in a variable.
314
+
Peerings are established between virtual network IDs. Obtain the ID of each virtual network with [az network vnet show](/cli/azure/network/vnet#az-network-vnet-show) and store the IDs in their respective variables.
315
315
316
316
```azurecli-interactive
317
317
# Get the id for vnet-1.
@@ -339,7 +339,7 @@ az network vnet peering create \
339
339
--allow-vnet-access
340
340
```
341
341
342
-
In the output returned after the previous command executes, you see that the **peeringState** is **Initiated**. The peering remains in the **Initiated** state until you create the peering from **vnet-2** to **vnet-1**. Create a peering from **vnet-2** to **vnet-1**.
342
+
In the output returned after the previous command executes, you see the **peeringState** is **Initiated**. The peering remains in the **Initiated** state until you create the peering from **vnet-2** to **vnet-1**. Create a peering from **vnet-2** to **vnet-1**.
343
343
344
344
```azurecli-interactive
345
345
az network vnet peering create \
@@ -350,7 +350,7 @@ az network vnet peering create \
350
350
--allow-vnet-access
351
351
```
352
352
353
-
In the output returned after the previous command executes, you see that the **peeringState** is **Connected**. Azure also changed the peering state of the **vnet-1-to-vnet-2** peering to **Connected**. Confirm that the peering state for the **vnet-1-to-vnet-2** peering changed to **Connected** with [az network vnet peering show](/cli/azure/network/vnet/peering#az-network-vnet-show).
353
+
In the output returned after the previous command executes, you see the **peeringState** is **Connected**. Azure also changed the peering state of the **vnet-1-to-vnet-2** peering to **Connected**. Confirm the peering state for the **vnet-1-to-vnet-2** peering changed to **Connected** with [az network vnet peering show](/cli/azure/network/vnet/peering#az-network-vnet-show).
354
354
355
355
```azurecli-interactive
356
356
az network vnet peering show \
@@ -366,7 +366,7 @@ Resources in one virtual network can't communicate with resources in the other v
366
366
367
367
## Create virtual machines
368
368
369
-
Test the communication between the virtual machines by creating a virtual machine in each virtual network. The virtual machines can communicate with each other over the virtual network peering.
369
+
Test the communication between the virtual machines by creating a virtual machine in each virtual network. The virtual machines can communicate with each other over the virtual network peering you just created.
370
370
371
371
### [Portal](#tab/portal)
372
372
@@ -387,13 +387,13 @@ Repeat the previous steps to create a second virtual machine in the second virtu
387
387
388
388
### Create the first virtual machine
389
389
390
-
Create a VM with [New-AzVM](/powershell/module/az.compute/new-azvm). The following example creates a VM named **vm-1** in the **vnet-1** virtual network. When prompted, enter the username and password for the virtual machine.
390
+
Create a virtual machine with [New-AzVM](/powershell/module/az.compute/new-azvm). The following example creates a virtual machine named **vm-1** in the **vnet-1** virtual network. When prompted, enter the username and password for the virtual machine.
391
391
392
392
```azurepowershell-interactive
393
393
# Create a credential object
394
394
$cred = Get-Credential
395
395
396
-
# Define the VM parameters
396
+
# Define the virtual machine parameters
397
397
$vmParams = @{
398
398
ResourceGroupName = "test-rg"
399
399
Location = "EastUS2"
@@ -406,17 +406,17 @@ $vmParams = @{
406
406
PublicIpAddressName = $null # No public IP address
407
407
}
408
408
409
-
# Create the VM
409
+
# Create the virtual machine
410
410
New-AzVM @vmParams
411
411
```
412
412
413
-
### Create the second VM
413
+
### Create the second virtual machine
414
414
415
415
```azurepowershell-interactive
416
416
# Create a credential object
417
417
$cred = Get-Credential
418
418
419
-
# Define the VM parameters
419
+
# Define the virtual machine parameters
420
420
$vmParams = @{
421
421
ResourceGroupName = "test-rg"
422
422
Location = "EastUS2"
@@ -429,15 +429,15 @@ $vmParams = @{
429
429
PublicIpAddressName = $null # No public IP address
430
430
}
431
431
432
-
# Create the VM
432
+
# Create the virtual machine
433
433
New-AzVM @vmParams
434
434
```
435
435
436
436
### [CLI](#tab/cli)
437
437
438
-
### Create the first VM
438
+
### Create the first virtual machine
439
439
440
-
Create a VM with [az vm create](/cli/azure/vm#az-vm-create). The following example creates a VM named **vm-1** in the **vnet-1** virtual network. If SSH keys don't already exist in a default key location, the command creates them. The `--no-wait` option creates the VM in the background, so you can continue to the next step.
440
+
Create a virtual machine with [az vm create](/cli/azure/vm#az-vm-create). The following example creates a virtual machine named **vm-1** in the **vnet-1** virtual network. If SSH keys don't already exist in a default key location, the command creates them. The `--no-wait` option creates the virtual machine in the background, so you can continue to the next step.
441
441
442
442
```azurecli-interactive
443
443
az vm create \
@@ -451,9 +451,9 @@ az vm create \
451
451
--no-wait
452
452
```
453
453
454
-
### Create the second VM
454
+
### Create the second virtual machine
455
455
456
-
Create a VM in the **vnet-2** virtual network.
456
+
Create a virtual machine in the **vnet-2** virtual network.
457
457
458
458
```azurecli-interactive
459
459
az vm create \
@@ -466,15 +466,15 @@ az vm create \
466
466
--authentication-type password
467
467
```
468
468
469
-
The VM takes a few minutes to create.
469
+
The virtual machine takes a few minutes to create.
470
470
471
471
---
472
472
473
473
Wait for the virtual machines to be created before continuing with the next steps.
474
474
475
475
## Connect to a virtual machine
476
476
477
-
Use `ping` to test the communication between the virtual machines. Sign-in to the Azure portal to complete the following steps.
477
+
Use `ping` to test the communication between the virtual machines. Signin to the Azure portal to complete the following steps.
478
478
479
479
1. In the portal, search for and select **Virtual machines**.
480
480
@@ -486,9 +486,9 @@ Use `ping` to test the communication between the virtual machines. Sign-in to th
486
486
487
487
1. Select **Use Bastion**.
488
488
489
-
1. Enter the username and password you created when you created the VM, and then select **Connect**.
489
+
1. Enter the username and password you created when you created the virtual machine, then select **Connect**.
490
490
491
-
## Communicate between VMs
491
+
## Communicate between virtual machines
492
492
493
493
1. At the bash prompt for **vm-1**, enter `ping -c 4 10.1.0.4`.
494
494
@@ -562,7 +562,7 @@ In this tutorial, you:
562
562
563
563
* Tested the communication between two virtual machines over the virtual network peering with `ping`.
0 commit comments