Learn how to create and manage virtual machines in Azure.
Azure Virtual Machines (VMs) provide on-demand, scalable computing resources. You can use Azure VMs to deploy and run applications that require greater control over the operating system than do solutions like containers, or that need to run in a specific environment. This tutorial will guide you through the essential steps of creating and configuring an Azure VM.
Before you begin, ensure you have:
We'll walk through creating a Linux VM using the Azure portal. The steps are similar for Windows VMs.
Open your web browser and go to https://portal.azure.com/. Sign in with your Azure account.
In the Azure portal search bar, type "Virtual machines" and select it from the services list.
On the Virtual machines page, click the "+ Create" button and then select "Virtual machine".
On the "Create a virtual machine" page, you'll need to fill out the following:
myResourceGroup
). Resource groups help organize Azure resources.myVM
).Standard_B1s
for cost-effectiveness.azureuser
).For this tutorial, the default settings for disks (e.g., OS disk type: Premium SSD
) are fine.
Defaults are generally suitable. Ensure you have a Virtual network and Subnet created or allow Azure to create them.
Click on the "Review + create" button. Azure will validate your configuration. Once validation passes, click "Create".
After the VM is deployed, you can connect to it.
If you created a Linux VM and used SSH key authentication:
Navigate back to your Virtual machine's overview page in the Azure portal. The public IP address will be listed there.
Use the following command, replacing <your_username>
, <your_private_key_path>
, and <public_ip_address>
with your actual values:
ssh -i <your_private_key_path> <your_username>@<public_ip_address>
If you used a password, the command would be:
ssh <your_username>@<public_ip_address>
You will be prompted to enter your password or confirm the connection.
If you created a Windows VM:
On the VM's overview page in the Azure portal, click the "Connect" button and select "RDP". Download the RDP file.
Double-click the downloaded file. You will be prompted for credentials. Use the username and password you set during VM creation.
Once connected, you can start managing your VM. Here are a few common tasks:
It's crucial to keep your VM's operating system and software up-to-date.
sudo apt update && sudo apt upgrade -y
sudo yum update -y
To save costs, you can stop your VM when not in use. Note that stopping deallocates the VM, freeing up compute resources.
You can restart your VM from the Azure portal or by using commands within the VM.
This tutorial covered the basics of creating and connecting to an Azure Virtual Machine. Here are some ideas for further learning:
Congratulations on successfully creating and connecting to your first Azure Virtual Machine!