DEV Community

Cover image for Ultimate Beginner's Guide to Azure Virtual Machines (VMs)
Surag
Surag

Posted on

Ultimate Beginner's Guide to Azure Virtual Machines (VMs)

Disclaimer: Warning—this guide may make you feel like a wizard once you finish! 🧙‍♂️ So get ready to create, launch, and manage your very own Azure Virtual Machine (VM) like a pro.

Introduction: What is a Virtual Machine (VM)?

Okay, let's start with the basics. A Virtual Machine (VM) is like a computer inside your computer (or inside a cloud, in this case). It's a virtual version of a physical machine, giving you access to computing power, storage, networking, and more—without ever needing to physically touch a server. It's all in the cloud! 🌩️

And why do you need a VM? Well, it can be used for a bunch of things: hosting applications, developing software, running multiple operating systems, and even gaming. It's like having a powerful remote PC you can access from anywhere.

Why Azure for VMs?

Alright, let’s get the elephant in the room out of the way: Why Azure? Why not some other cloud service provider?

Azure, Microsoft’s cloud platform, is highly reliable, secure, and offers pay-as-you-go pricing. So you’re only paying for what you use—meaning you’re not going to wake up one day with a surprise bill (though you still might want to set up some spending limits, just to be safe). 😅

With Azure, you get access to a vast global network of datacenters. The cherry on top? Azure's deep integration with Microsoft's other services like Office 365, Active Directory, and PowerShell.

Ready to dive in? No worries, I'm here every step of the way! 🧑‍🏫

Setting Up Your First Azure Virtual Machine (VM)

We’re going to take this step-by-step like it’s a cooking recipe (minus the burnt toast). Here's how to cook up your very first VM on Azure. Ready?

Step 1: Sign Up for an Azure Account

First things first, you need an Azure account. Don’t have one? No problem—Microsoft has this magical thing called Azure Free Account which gives you $200 worth of credits to play around with, for the first 30 days.

To sign up for your Azure Free Account, visit Azure Free Account.

You’re now officially one step closer to cloud wizardry. 👏

Step 2: Accessing the Azure Portal

Once you've got your account, head over to the Azure Portal at https://portal.azure.com. Think of it as your cockpit in the cloud where you'll pilot all your VMs, apps, and more.

Pro Tip: Bookmark it—you’ll be coming back to this URL often.

Step 3: Create a New Virtual Machine

Here’s where the magic happens. 🎩🐇

Inside the Azure Portal, look for the big blue "+ Create a resource" button on the left-hand side.

Next, search for “Virtual Machine” in the search bar, or select it from the list.

Click on the “Create” button under Virtual Machine.

Boom, you’re on your way to cloud greatness! 🎉

Configuring Your Virtual Machine (VM)

Now we’ve arrived at the fun part—the actual creation of your Virtual Machine. No, it doesn’t involve casting any spells, but it does involve making a few key decisions. Let’s break it down step by step, kind of like assembling IKEA furniture—without the missing screws. 😉

  1. Subscription & Resource Group

Subscription: This will default to the subscription you set up with your Azure account. Choose wisely (or not; it’s probably your only one).

Resource Group: Resource groups are like containers that hold your VM and all the other associated resources. If you don’t have a resource group yet, click “Create New” and give it a memorable name like “MyFirstVM_Group”. Easy, right?

  1. VM Name & Region

Virtual Machine Name: Give your VM a cool name, like "CloudHeroVM" or “EpicServer123.” Don’t worry, you can always change it later, but it's a fun moment to show off your creativity. 🎨

Region: Choose the region closest to you for optimal performance. For instance, if you're in Europe, go for “West Europe” or “UK South.”

  1. Image & Size

This is where you pick the Operating System (OS) and the hardware specifications for your VM.

Image: Choose your OS. The most common choices are Windows Server and Ubuntu Linux. For beginners, Ubuntu tends to be a favorite (free and open-source), but Windows is great if you're already familiar with it.

Size: This is where you select the specs for your VM—how many CPUs and how much RAM you want. Keep it modest for now—something like Standard_B1s (1 vCPU, 1 GB RAM) is perfect for starting out. You can scale up later if needed.

Pro Tip: The cheaper options are great for small workloads or learning purposes. You won’t need the virtual equivalent of a space shuttle just yet.

  1. Administrator Account

You’ll need to set up a username and password for accessing your VM. Pro-tip here: use something secure, like a combo of upper/lowercase letters, numbers, and special characters. And don’t use "password123." Please. 🙏

Username: Anything you like. For example, "cloud_user."

Password: A secure password.

  1. Public Inbound Ports

This part can sound scary, but don’t worry. You need to specify which ports can be used to access your VM from the internet.

For simplicity, allow SSH (22) for Linux or RDP (3389) for Windows.

Deploying Your Virtual Machine

Once you’ve got all the configurations set, hit Review + Create at the bottom of the page.

Azure will take a few moments to validate everything and then present you with a summary. If all looks good, click Create. 🎉

Now, you wait for Azure to work its magic. In a few minutes (or seconds, depending on the size of your VM), you’ll get a notification that your VM is up and running.

Connecting to Your Virtual Machine (VM)

Congratulations! You’ve just deployed your first VM. Now, let’s connect to it.

For Windows VMs:

Click on the "Connect" button at the top of your VM’s overview page.

Choose RDP (Remote Desktop Protocol).

Download the .rdp file and open it. You’ll be prompted to enter the username and password you set earlier.

For Linux VMs:

Open up your terminal (Windows users, you can use PowerShell).

Type the following SSH command:

bashCopy codessh username@your_vm_public_ip

Make sure to replace username with your actual username and your_vm_public_ip with the public IP address of your VM (which you can find in the Azure Portal under your VM's overview page).

Boom, you’re in! 🎉

Post-Deployment Tasks: Keeping Your VM Safe & Cost-Effective

Now that your VM is up and running, it’s time to keep things secure and efficient.

Enable Auto-shutdown:
Azure gives you the ability to automatically shut down your VM during off-hours, helping you save money. You can enable this feature from the Azure Portal under your VM’s settings.

Set Up Backups:
Accidents happen, so it's always a good idea to set up backups for your VM. Azure Backup is a service that can automate this process. You can set it up in just a few clicks from the Azure Portal.

Monitor Usage:
Keep an eye on your VM’s resource usage (CPU, memory, network traffic) using Azure Monitor. If your VM starts to struggle under the load, you might need to scale up your resources or optimize your apps.

Scaling Your Virtual Machine: The Sky's the Limit

Let’s say your app gets popular—yay, success! But now your VM is getting overloaded—oh no! 😱

Don’t worry, scaling up your VM is super easy. Azure lets you change the size of your VM without losing any data. Just go to the VM Size section in the Azure Portal and pick a bigger instance.

Need to handle even more load? Consider adding more VMs and using a Load Balancer to distribute the traffic.

Conclusion: You're Now a Cloud Sorcerer! 🧙‍♂️

Well, would you look at that—you’ve just successfully set up, deployed, and connected to your very first Azure Virtual Machine. Whether you're using it to host a website, run applications, or even experiment with machine learning—you're officially part of the cloud generation.

Now go forth, conjure more VMs, explore Azure’s vast range of services, and level up your cloud knowledge.

Top comments (0)