Connecting to Virtual Machines – Azure Virtual Machines

As an administrator, you need to connect to the virtual machines to change the virtual machine configuration you created or install some roles such as database, web, or messaging. Though there is no drastic change in how to deploy a Windows versus Linux VM, the way you connect to them is different. For Windows and Linux machines, there are a different set of connectivity options. In both scenarios, you are connecting to the public IP address of the virtual machine. Let’s explore the options.

Windows Connections

You can connect to Windows machines using two options, namely, Remote Desktop Protocol (RDP) and Windows Remote Management (WinRM).

Remote Desktop Protocol

You can connect to the graphical user interface (GUI) of the Windows VM using RDP. RDP uses TCP port 3389, and you need to make sure that you have opened this port in your NSG to establish connectivity. If you navigate to the Azure portal, go to Virtual Machines, and open the Windows VM you created in Exercise 7.1. You will see the Connect button on the Overview blade (refer to Figure 7.3). Clicking this button will show you the RDP option to download the RDP file.

FIGURE 7.3 Downloading the RDP file

Let’s see how you can connect to the Windows VM using RDP; see Exercise 7.2.

EXERCISE 7.2
 Connecting to a Windows VM Using RDP

  1. Sign in to the Azure portal and search for virtual. Click Virtual Machines in the search results.
  2. Select the Windows VM from the list of VMs and click Connect from the Overview blade (refer to Figure 7.3).
  3. Click Download RDP File on the next screen.
  1. A file with an .rdp extension will be downloaded to your computer, and you need to open it. If you are using a Windows computer, then you will have a built-in RDP client provided by Microsoft. If you are performing this lab from a Linux or macOS computer, then you may need to download the RDP client to connect via RDP.
  2. Opening the file will give you a warning that the publisher is not identified. You can ignore this warning, as you know that the IP address corresponds to the VM you created. Click the Connect button.

6. You will be asked to enter the credentials for the VM. You can use the username and password entered during the VM creation. If you are using a domain-joined computer, you may see that the system is trying to connect using your domain credentials. You can click More Choices and select Use A Different Account to get the screen shown here.

  1. After entering your credentials, you can connect to the VM. You will see a certificate warning; you can ignore this as you trust the remote computer. Click Yes to proceed with the connection.
  2. Soon, you will be connected to the Windows GUI, and you can work with the Windows VM over RDP.

You can work with the Windows VM as you normally work with a Windows machine. Further, you can install the IIS role on the VM and run a web server. To verify the working of web server, you need to make sure that you allowed HTTP traffic on your NSG. Now let’s review the second method to connect to Windows VMs.