Hands-on – Create and Connect to the Virtual Machine in Azure


This demonstration will guide you through creating a virtual machine in Microsoft Azure, configuring it, and connecting to it remotely via Remote Desktop Protocol (RDP) (for Windows VMs) or SSH (for Linux VMs).

We'll break the steps into two parts:

  1. Create the Virtual Machine in Azure

  2. Connect to the Virtual Machine

Part 1: Create the Virtual Machine in Azure

Step 1: Sign in to the Azure Portal

  1. Go to the Azure Portal:

  2. Sign in with your Azure account (or create one if you don't have one).

Step 2: Create a New Virtual Machine

  1. In the Azure Portal, click on the "Create a resource" button in the top left.

  2. In the "Search the Marketplace" box, type "Virtual Machine" and select "Virtual Machine" from the list.

  3. Click "Create" to start the VM creation process.

Step 3: Configure Basic Settings for the Virtual Machine

  1. Subscription: Choose the subscription where you want the VM to be created.

  2. Resource Group: Create a new resource group or use an existing one (e.g., "MyVMResourceGroup").

  3. Virtual Machine Name: Provide a unique name for your VM (e.g., "MyFirstVM").

  4. Region: Choose a region where you want the VM to be located (e.g., "East US").

  5. Availability Options: Select No infrastructure redundancy required for simplicity, or choose Availability Zones for high availability.

  6. Image: Select an operating system image (e.g., Windows Server 2022 Datacenter or Ubuntu 20.04 LTS).

  7. Size: Choose the VM size (e.g., Standard B1s for a small, cost-effective VM). You can click on "See all sizes" to pick a different size.

  8. Authentication Type: Choose Password (for Windows) or SSH public key (for Linux).

    • For Windows: Set a username and password.

    • For Linux: Generate and upload an SSH public key.

  9. Inbound Port Rules: Allow RDP (for Windows) or SSH (for Linux) to connect to the VM.

Once you’ve configured these settings, click "Next: Disks".

Step 4: Configure Disks

  1. OS Disk: Choose the disk type. You can use Standard SSD or Premium SSD for production workloads.

  2. Data Disks: Optionally, you can add additional data disks, but for this basic demo, we'll leave this empty.

Click "Next: Networking".

Step 5: Configure Networking

  1. Virtual Network (VNet): You can either create a new VNet or use an existing one. If you create a new VNet, Azure will automatically create a subnet for the VM.

  2. Subnet: Choose or create a subnet for the VM.

  3. Public IP: Select Create new (this is necessary for remote access). Azure will assign a dynamic IP address.

  4. Network Security Group (NSG): Choose Basic and add inbound rules for RDP (port 3389 for Windows) or SSH (port 22 for Linux).

  5. Public IP Address: This will be assigned automatically. You can keep it Dynamic or set it to Static (for a fixed IP).

Click "Next: Management".

Step 6: Configure Management Settings

  1. Monitoring: Enable Boot Diagnostics for troubleshooting, and enable OS Guest Diagnostics for VM monitoring.

  2. Identity and Auto-shutdown: You can enable auto-shutdown to save costs when the VM is not in use.

Click "Next: Advanced" (you can leave the defaults here) and then "Next: Tags".

Step 7: Review and Create

  1. Review the configuration settings.

  2. If everything looks good, click "Create".

Azure will now begin the process of deploying the virtual machine. This process may take a few minutes.

Part 2: Connect to the Virtual Machine

Once the VM is successfully created, you can connect to it remotely.

For Windows Virtual Machines (Using RDP)

  1. Go to the VM: In the Azure Portal, navigate to "Virtual Machines" and select the VM you just created.

  2. Get the Public IP Address: On the VM overview page, find the Public IP address of the VM.

  3. Connect via RDP: Open Remote Desktop Connection on your computer (search for "Remote Desktop" in Windows).

  4. In the Remote Desktop window, enter the Public IP address of the VM.

  5. Click Connect. When prompted, enter the username and password that you configured during VM creation.

  6. Log in: After entering the credentials, you should be logged into your VM via RDP.

For Linux Virtual Machines (Using SSH)

  1. Get the Public IP Address: Like with Windows VMs, find the Public IP address of the VM in the Azure Portal.

  2. Use SSH to Connect: On your local machine, open a terminal (Linux/macOS) or an SSH client (Windows, such as PowerShell or PuTTY).

  3. If you are using SSH keys, make sure your private key is available on your local machine.

  4. Connect using the following command:

    • Replace username with the username you configured during VM creation and <public_ip_address> with the IP address of the VM.

  1. If you're using an SSH key, specify the path to your private key:

  1. Log in: You should now be connected to your Linux VM via SSH.

Troubleshooting Tips

  1. Firewall or NSG issues: If you can't connect, check your Network Security Group (NSG) settings to make sure that port 3389 (RDP) or port 22 (SSH) is open.

  2. VM is not reachable: Ensure the VM is running. You can start it from the Azure Portal if it is stopped.

  3. SSH Key issues: If you're using SSH, ensure that the SSH private key is accessible on your local machine and is associated with the correct user.

Summary

In this demonstration, you learned how to:

  1. Create a Virtual Machine in Azure.

  2. Configure VM settings, including selecting an image, disk, and networking options.

  3. Connect to the Virtual Machine via RDP (for Windows VMs) or SSH (for Linux VMs).

With this basic understanding, you can now create and manage Azure VMs for various use cases.

 

Related Articles


Rajnish, MCT

Leave a Reply

Your email address will not be published. Required fields are marked *


SUBSCRIBE

My newsletter for exclusive content and offers. Type email and hit Enter.

No spam ever. Unsubscribe anytime.
Read the Privacy Policy.