Table of contents
- Step 1: Sign In to Azure Portal
- Step 2: Create a New Resource
- Step 3: Configure the Basics
- Step 4: Configure the Disk
- Step 5: Configure Networking
- Step 6: Configure Management Options
- Step 7: Configure Monitoring Options
- Step 8: Configure Advanced Options (Optional)
- Step 9: Add Tags
- Step 10: Review and Create
- Step 11: Connect to Your Linux VM
- Step 12: Start Using Your VM
- Tips for Managing Your Linux VM
Creating a virtual machine (VM) on Azure is a straightforward process, and it’s a powerful way to access on-demand computing resources. In this guide, we’ll walk you through the process of creating a Linux virtual machine on Microsoft Azure, step by step.
Step 1: Sign In to Azure Portal
Navigate to the Azure Portal.
Login with your Microsoft account. If you don’t have an account, you can create one for free.
Step 2: Create a New Resource
Once logged in, click on the "Create a resource" button in the left-hand menu.
In the search bar, type "Virtual Machine" and select "Virtual Machine" from the results.
Click on the "Create" button to start configuring your VM.
Step 3: Configure the Basics
On the Basics tab, you’ll configure the primary settings of your Linux VM.
Subscription: Select the Azure subscription you want to use.
Resource Group: Either select an existing resource group or create a new one by clicking "Create new" and giving it a name.
Virtual Machine Name: Enter a unique name for your VM (e.g.,
myLinuxVM
).Region: Choose the Azure region closest to you for optimal performance and lower latency (e.g. (Europe) UK Soutth).
Availabilty zone: Select the availability zones for your virtual machine. For high availabilty, more than one zone can be selected. Use the dropdown to see all the zones.
Image: Click ”See all images” and select your desired Linux distribution (e.g., Ubuntu Server 22.04 LTS).
Size: Click "See all sizes" and select a VM size based on your performance needs and budget. Remember to click the ”Select” button after choosing a VM size.
Authentication Type: Choose between SSH public key (recommended for security) or Password.
If you select SSH public key, provide your public key, or generate a new one.
If you select Password, set a strong username and password.
Take note of the Username as this will be used later for remote connection to the VM.
Inbound Port Rules: Select Allow selected ports and choose SSH (22) to enable remote access. Use the dropdown to see all available ports.
Click Next: Disks.
Step 4: Configure the Disk
OS Disk Type: Choose the disk type (SSD for performance or HDD for cost savings).
Optionally, add a data disk by clicking "Create and attach a new disk" for additional storage.
Click Next: Networking.
Step 5: Configure Networking
Virtual Network (VNet): Use the default VNet or create a new one for your VM.
Subnet: Select a subnet for the VM.
Public IP: Leave the default to automatically assign a public IP.
NIC Network Security Group: Choose Basic and allow SSH (22) if not already selected.
Click Next: Management.
Step 6: Configure Management Options
Auto-Shutdown: Configure auto-shutdown if needed to save costs during inactive periods.
Backup: Enable Azure Backup for disaster recovery if required.
Click Next: Monitoring.
Step 7: Configure Monitoring Options
Decide whether to enable monitoring options like Boot diagnostics and guest OS diagnostics.
Click Next: Advanced
Step 8: Configure Advanced Options (Optional)
Add scripts, configurations, or extensions if required for custom initialization.
Skip this step if you don’t need any additional setup.
Click Next: Tags.
Step 9: Add Tags
Tags are optional but useful for organizing and tracking resources. Add key-value pairs to label your VM (e.g., Environment: Development
).
Click Next: Review + Create.
Step 10: Review and Create
Review all the configuration details of your VM.
Click "Create" to start the deployment process. This can take a few minutes.
When prompted, click ”Download private key and create resource” to download private key pair. This will only show up if you have selected SSH as the Authentication type in Step 3 and you have chosen to Generate new key pair
Step 11: Connect to Your Linux VM
Once your VM is deployed, you’ll receive a notification. Click ”Go to resource” to navigate to the virtual machine interface in the Azure Portal
From the ”Connect” dropdown tab, click Connect. Make a note of the Public IP address and the Admin username. These will be used, with the downloaded private key pair, to SSH into the virtual machine from our local machine.
Copy the SSH command provided and paste it into your terminal:
ssh -i </path/to/downloaded/private/key.pem> <username>@<ip_address>
We are using Windows PowerShell terminal as shown below. When promted to authenticate, type yes.
Step 12: Start Using Your VM
Congratulations! You now have a fully functional Linux virtual machine running on Azure. You can use it to host applications, run scripts, or practice Linux commands.
Tips for Managing Your Linux VM
Security: Always keep your VM secure by regularly updating the OS and restricting inbound traffic.
Cost Optimization: Shut down your VM when not in use to save costs.
Scaling: If you need more resources, Azure allows you to resize your VM as needed.
By following this guide, you’ve successfully created a Linux virtual machine in Azure. For more insights and tutorials, keep following my blog! 🚀