Create a Linux Virtual Machine
This guide walks you through the essential steps to deploy a Linux virtual machine (VM) in Azure using the Azure portal. Azure VMs provide scalable, on-demand computing resources.
Prerequisites
- An active Azure account. If you don't have one, you can create a free account.
Step 1: Sign in to the Azure portal
Open your web browser and navigate to https://portal.azure.com. Sign in with your Azure account credentials.
Step 2: Create a Virtual Machine
- In the Azure portal, select Create a resource from the top menu (the plus sign).
- In the search box, type Virtual machine and select Virtual machine from the results.
- Click Create.
Step 3: Configure VM Basics
On the Basics tab, configure the following:
- Subscription: Select your Azure subscription.
- Resource group: Click Create new and enter a name for the resource group, e.g.,
myResourceGroup
. A resource group is a logical container for Azure resources. - Virtual machine name: Enter a name for your VM, e.g.,
myVM
. - Region: Select an Azure region close to you, e.g.,
East US
. - Availability options: For this quickstart, you can leave the default.
- Security type: Choose Standard.
- Image: Select a Linux distribution, e.g.,
Ubuntu Server 20.04 LTS - Gen2
. - Size: Choose a VM size. For this quickstart,
Standard_B1s
is a good cost-effective option. - Username: Enter a username for the VM administrator, e.g.,
azureuser
. - Authentication type: Select SSH public key.
- SSH public key source: Select Generate new key pair.
- SSH public key name: Enter a name for your key pair, e.g.,
myVM_key
. You will be prompted to download the private key later.
Step 4: Configure Disks
On the Disks tab, you can configure the operating system disk. For this quickstart, the default settings are fine.
Step 5: Configure Networking
On the Networking tab, you can configure networking settings. By default, Azure creates a virtual network, subnet, public IP address, and network security group. For this quickstart, the defaults are sufficient.
Step 6: Review and Create
Review the settings you've configured on the Review + create tab. Ensure everything is correct. You will also see an option to download the private key for your SSH public key pair. Download your private key now and save it securely.
Important: Keep your private key secure. You will need it to connect to your VM.
Click Create to start the VM deployment.
Step 7: Connect to the Virtual Machine
Once the deployment is complete (this may take a few minutes), you can connect to your VM.
- Navigate back to the Azure portal and find your virtual machine.
- On the Overview page, you will find the VM's public IP address. Copy this IP address.
- Open a terminal or SSH client on your local machine.
- Use the following command to connect, replacing
<public-ip-address>
with your VM's IP address and<path-to-private-key>
with the path to the private key file you downloaded:
ssh -i <path-to-private-key> azureuser@<public-ip-address>
You might be prompted to confirm the host's authenticity. Type yes
and press Enter.
Next Steps
Congratulations! You have successfully created and connected to your Azure virtual machine. You can now:
- Install applications and configure services.
- Manage your VM's disks, networking, and security settings.
- Explore other Azure services to enhance your VM.