Skip to content

Commit ecfa77f

Browse files
committed
finished adding powershell
1 parent 4563186 commit ecfa77f

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

articles/virtual-network/tutorial-connect-virtual-networks-portal.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ $subConfig = @{
105105
AddressPrefix = "10.0.0.0/24"
106106
VirtualNetwork = $virtualNetwork1
107107
}
108-
$subnetConfig = Add-AzVirtualNetworkSubnetConfig @subConfig
108+
$subnetConfig1 = Add-AzVirtualNetworkSubnetConfig @subConfig
109109
```
110110

111111
Create a subnet configuration for Azure Bastion with [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig). The following example creates a subnet configuration with a **10.0.1.0/24** address prefix:
112112

113113
```azurepowershell-interactive
114-
$subConfig = @{
114+
$subBConfig = @{
115115
Name = "AzureBastionSubnet"
116116
AddressPrefix = "10.0.1.0/24"
117117
VirtualNetwork = $virtualNetwork1
118118
}
119-
$subnetConfig = Add-AzVirtualNetworkSubnetConfig @subConfig
119+
$subnetConfig2 = Add-AzVirtualNetworkSubnetConfig @subBConfig
120120
```
121121

122122
Write the subnet configuration to the virtual network with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork), which creates the subnet:
@@ -162,13 +162,13 @@ Create a second virtual network with [New-AzVirtualNetwork](/powershell/module/a
162162
>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.
163163
164164
```azurepowershell-interactive
165-
$vnet1 = @{
165+
$vnet2 = @{
166166
ResourceGroupName = "test-rg"
167167
Location = "EastUS2"
168168
Name = "vnet-2"
169169
AddressPrefix = "10.1.0.0/16"
170170
}
171-
$virtualNetwork1 = New-AzVirtualNetwork @vnet1
171+
$virtualNetwork2 = New-AzVirtualNetwork @vnet2
172172
```
173173

174174
Create a subnet configuration with [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig). The following example creates a subnet configuration with a **10.1.0.0/24** address prefix:
@@ -177,11 +177,17 @@ Create a subnet configuration with [Add-AzVirtualNetworkSubnetConfig](/powershel
177177
$subConfig = @{
178178
Name = "subnet-1"
179179
AddressPrefix = "10.1.0.0/24"
180-
VirtualNetwork = $virtualNetwork1
180+
VirtualNetwork = $virtualNetwork2
181181
}
182182
$subnetConfig = Add-AzVirtualNetworkSubnetConfig @subConfig
183183
```
184184

185+
Write the subnet configuration to the virtual network with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork), which creates the subnet:
186+
187+
```azurepowershell-interactive
188+
$virtualNetwork2 | Set-AzVirtualNetwork
189+
```
190+
185191
### [CLI](#tab/cli)
186192

187193
---
@@ -257,7 +263,7 @@ Repeat the previous steps to create a second virtual machine in the second virtu
257263

258264
### Create the first VM
259265

260-
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. The `-AsJob` option creates the VM in the background, so you can continue to the next step. When prompted, enter the user name and password for the virtual machine.
266+
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.
261267

262268
```azurepowershell-interactive
263269
# Create a credential object
@@ -313,7 +319,7 @@ Wait for the virtual machines to be created before continuing with the next step
313319

314320
## Connect to a virtual machine
315321

316-
Use `ping` to test the communication between the virtual machines.
322+
Use `ping` to test the communication between the virtual machines. Sign-in to the Azure portal to complete the following steps.
317323

318324
1. In the portal, search for and select **Virtual machines**.
319325

@@ -329,34 +335,38 @@ Use `ping` to test the communication between the virtual machines.
329335

330336
## Communicate between VMs
331337

332-
1. At the bash prompt for **vm-1**, enter `ping -c 4 vm-2`.
338+
1. At the bash prompt for **vm-1**, enter `ping -c 4 10.1.0.4`.
333339

334340
You get a reply similar to the following message:
335341

336342
```output
337-
azureuser@vm-1:~$ ping -c 4 vm-2
338-
PING vm-2.3bnkevn3313ujpr5l1kqop4n4d.cx.internal.cloudapp.net (10.1.0.4) 56(84) bytes of data.
339-
64 bytes from vm-2.internal.cloudapp.net (10.1.0.4): icmp_seq=1 ttl=64 time=1.83 ms
340-
64 bytes from vm-2.internal.cloudapp.net (10.1.0.4): icmp_seq=2 ttl=64 time=0.987 ms
341-
64 bytes from vm-2.internal.cloudapp.net (10.1.0.4): icmp_seq=3 ttl=64 time=0.864 ms
342-
64 bytes from vm-2.internal.cloudapp.net (10.1.0.4): icmp_seq=4 ttl=64 time=0.890 ms
343+
azureuser@vm-1:~$ ping -c 4 10.1.0.4
344+
PING 10.1.0.4 (10.1.0.4) 56(84) bytes of data.
345+
64 bytes from 10.1.0.4: icmp_seq=1 ttl=64 time=2.29 ms
346+
64 bytes from 10.1.0.4: icmp_seq=2 ttl=64 time=1.06 ms
347+
64 bytes from 10.1.0.4: icmp_seq=3 ttl=64 time=1.30 ms
348+
64 bytes from 10.1.0.4: icmp_seq=4 ttl=64 time=0.998 ms
349+
350+
--- 10.1.0.4 ping statistics ---
351+
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
352+
rtt min/avg/max/mdev = 0.998/1.411/2.292/0.520 ms
343353
```
344354
345355
1. Close the Bastion connection to **vm-1**.
346356
347357
1. Repeat the steps in [Connect to a virtual machine](#connect-to-a-virtual-machine) to connect to **vm-2**.
348358
349-
1. At the bash prompt for **vm-2**, enter `ping -c 4 vm-1`.
359+
1. At the bash prompt for **vm-2**, enter `ping -c 4 10.0.0.4`.
350360
351361
You get a reply similar to the following message:
352362
353363
```output
354-
azureuser@vm-2:~$ ping -c 4 vm-1
355-
PING vm-1.3bnkevn3313ujpr5l1kqop4n4d.cx.internal.cloudapp.net (10.0.0.4) 56(84) bytes of data.
356-
64 bytes from vm-1.internal.cloudapp.net (10.0.0.4): icmp_seq=1 ttl=64 time=0.695 ms
357-
64 bytes from vm-1.internal.cloudapp.net (10.0.0.4): icmp_seq=2 ttl=64 time=0.896 ms
358-
64 bytes from vm-1.internal.cloudapp.net (10.0.0.4): icmp_seq=3 ttl=64 time=3.43 ms
359-
64 bytes from vm-1.internal.cloudapp.net (10.0.0.4): icmp_seq=4 ttl=64 time=0.780 ms
364+
azureuser@vm-2:~$ ping -c 4 10.0.0.4
365+
PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
366+
64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=1.81 ms
367+
64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=3.35 ms
368+
64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=0.811 ms
369+
64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=1.28 ms
360370
```
361371
362372
1. Close the Bastion connection to **vm-2**.

0 commit comments

Comments
 (0)