04 - Create a virtual network (20 min)
In this walkthrough, we will create a virtual network, deploy two virtual machines onto that virtual network and then configure them to allow one virtual machine to ping the other within that virtual network.
Task 1: Create a virtual network
In this task, we will create a virtual network.
-
Sign in to the Azure portal at https://portal.azure.com
-
From the All services blade, search for and select Virtual networks, and then click + Add, + Create, + New.
-
On the Basics tab, fill in the following information (leave the defaults for everything else):
Setting Value Subscription Leave default provided Resource Group Create new resource group Name vnet1 Region (US) East US -
Click the Review + create button. Ensure the validation passes.
Task 2: Create two virtual machines
In this task, we will create two virtual machines in the virtual network.
-
From the All services blade, search for Virtual machines and then click + Add, + Create, + New, from the drop down select Virtual Machine.
-
On the Basics tab, fill in the following information (leave the defaults for everything else):
Setting Value Subscription Use default supplied Resource group Select default in drop down Virtual machine name vm1 Region (US) East US Image Windows Server 2019 Datacenter - Gen1 Username azureuser Password Pa$$w0rd1234 Public inbound ports Select Allow selected ports Selected inbound ports RDP (3389) -
Select the Networking tab. Make sure the virtual machine is placed in the vnet1 virtual network. Review the default settings, but do not make any other changes.
-
Click Review + create. After the Validation passes, click Create. Deployment times can vary but it can generally take between three to six minutes to deploy.
-
Monitor your deployment, but continue on to the next step.
-
Create a second virtual machine by repeating steps 2 to 4 above. Make sure you use a different virtual machine name, that the virtual machine is in the same virtual network, and is using a new public IP address:
Setting Value Resource group myRGVNet Virtual machine name vm2 Virtual network vnet1 Public IP vm2-ip -
Wait for both virtual machines to deploy and status says running.
Task 3: Test the connection
In this task, we will try to test whether the virtual machines can communicate (ping) each other. If not we will install a rule to allow an ICMP connection. Usually ICMP coonnections are automatically blocked.
-
From the All resources blade, search for vm1, open its Overview blade, and make sure its Status is Running. You may need to Refresh the page.
-
On the Overview blade, select Connect and then select RDP from the drop down.
Note: The following directions tell you how to connect to your VM from a Windows computer.
-
On the Connect with RDP blade, keep the default options to connect by IP address over port 3389 and click Download RDP File.
-
Open the downloaded RDP file (located at the bottom left of you VM) and click Connect when prompted.
-
In the Windows Security window, type the username azureuser and password Pa$$w0rd1234 and then click OK.
-
You may receive a certificate warning during the sign-in process. Click Yes to create the connection and connect to your deployed VM. You should connect successfully. Close the Windows Server and Dashboard windows that pop up. You should see a Blue Windows background. You are now in your virtual machine.
-
Open up PowerShell on the virtual machine by clicking the Start button, and in Search type PowerShell, right click on Windows PowerShell to Run as administrator
-
In Powershell, try to ping vm2 by typing:
ping vm2
-
You should be successful. You have pinged VM2 from VM1.
Congratulations! You have configured and deployed two virtual machines in a virtual network, and then you were able to connect them.
Note: To avoid additional costs, you can remove this resource group. Search for resource groups, click your resource group, and then click Delete resource group. Verify the name of the resource group and then click Delete. Monitor the Notifications to see how the delete is proceeding.