How to run Ubuntu on Azure
Enjoying this content? Subscribe to the Channel!
Unleash the Power of Linux: Deploying Ubuntu on Microsoft Azure Step-by-Step
Welcome back to Darren’s Tech Tutorials!
We often talk about the power of the cloud, but what happens when you combine that raw power with the flexibility of open-source software? You get a high-performance, cost-effective development environment!
In this comprehensive guide, we’re walking through the precise steps necessary to set up, secure, connect to, and ultimately decommission a powerful Ubuntu Linux Virtual Machine (VM) right inside Microsoft Azure. Whether you’re a seasoned developer or just dipping your toes into cloud hosting, this tutorial will make setting up your first Linux cloud server simple and secure.
Getting Started: Selecting the Ubuntu Image
The very first step in provisioning any cloud machine is selecting the base operating system image. Azure makes this incredibly easy through the Azure Marketplace.
- Navigate to Virtual Machines: In the Azure Portal, search for and select “Virtual Machines.”
- Create a New VM: Click “Create” and then select “Virtual Machine.”
- Search the Marketplace: Look for the “Image” selection dropdown. You will see many popular options listed, but we specifically need Ubuntu. Search for and select the latest stable Ubuntu Server image (often designated as LTS, or Long-Term Support). This is the open-source distribution of Linux we will be using.
Setting Up Your Azure Ubuntu VM
Once the image is selected, you must define the foundational parameters for your new cloud instance. Pay close attention to these details, especially those related to cost and security.
- Define the Resource Group: Create a new Resource Group (e.g.,
Ubuntu-Demo-RG). Resource Groups are essential for organizing and, more importantly, easily deleting all related components later. - VM Name and Region: Give your VM a unique name (e.g.,
Ubuntu-Test-Server) and select the Azure Region closest to you for the best performance. - VM Size: This is a crucial cost consideration. Select the appropriate VM Size (e.g.,
Standard_B1sfor basic testing, or something larger if you need more processing power). Remember that costs are directly tied to the size and uptime of the VM. - Authentication Method: For connecting to a Linux server, SSH public key is the industry standard for security. However, for a simple tutorial setup, you may select Password. If you choose Password, ensure it is complex and secure, and remember the username you create (e.g.,
azureuser). - Networking Defaults: When prompted for network settings, Azure will automatically create a Virtual Network (VNet) and a Network Security Group (NSG). We will tighten these security settings in the next step.
- Review and Create: Review your configuration and click “Create.” Azure will begin deploying the Ubuntu VM, which usually takes just a few minutes.
Essential Security: Restricting Network Access
Security should always be your top priority. By default, Azure may expose your VM’s SSH port (Port 22) to the entire internet. We must restrict access so only your current computer can connect.
When you are configuring the VM’s Network Security Group (NSG) settings (either during the creation process or immediately after the VM is provisioned):
- Identify the SSH Rule: Locate the Inbound Security Rule that allows traffic on Port 22 (SSH).
- Change the Source: Change the “Source” setting for the Port 22 rule from “Any” or “Internet” to “My IP address.”
- Apply the Change: Azure will automatically detect your current public IP address and apply the restriction. This ensures that any hacker attempting to probe Port 22 from a different location will be instantly blocked by Azure’s firewall layer.
Pro Tip: If your IP address changes (common for home connections), you will need to update this NSG rule before you can connect again.
Connecting to Your VM with PuTTY
Now that your Ubuntu machine is running securely in the cloud, it’s time to log in! Since most Windows users don’t have a native SSH client, we use the free tool PuTTY.
- Obtain the Public IP: In the Azure portal, navigate to your newly created Ubuntu VM and copy the Public IP Address.
- Open PuTTY: Launch the PuTTY application on your local machine.
- Enter Connection Details:
- Paste the Public IP Address into the “Host Name (or IP address)” field.
- Ensure the Port is set to 22 and the Connection Type is SSH.
- Connect: Click “Open.” You may receive a security alert the first time you connect; accept it.
- Log In: The terminal window will prompt you for your login credentials:
login as:Enter the username you defined during VM setup (e.g.,azureuser).password:Enter the password you set.
Congratulations! You are now logged into your Ubuntu Linux VM running live in the Microsoft Azure cloud. You can begin installing packages, running scripts, and utilizing the cloud infrastructure immediately.
The Crucial Final Step: Cleaning Up Azure Resources
This is perhaps the most important administrative step, especially if you are using Azure for testing or free tier services. Azure charges you for resources that are provisioned, even if you are not actively using them.
To avoid unexpected costs, we must completely delete everything we created.
- Locate the Resource Group: Go back to the Azure Portal and find the Resource Group you created at the very beginning (e.g.,
Ubuntu-Demo-RG). - Delete the Resource Group: Select the Resource Group and click Delete Resource Group.
- Confirmation: You will be required to type the name of the Resource Group to confirm deletion. This is a failsafe because deleting a Resource Group deletes everything inside it—the VM, the network interfaces, the public IP, the storage, and the NSG.
Once the deletion process is complete, you can rest assured that your Azure account will not accrue any further costs related to this tutorial!
Running Linux on Azure is a fantastic way to blend the power of open-source with the reliability of enterprise cloud architecture. Now that you’ve mastered the setup and, most importantly, the security and cleanup process, you are ready to tackle more advanced cloud concepts.
Did you find this tutorial helpful? Let us know in the comments below! Be sure to like this post and subscribe to Darren’s Tech Tutorials for more clear, actionable guides to the world of technology. Happy cloud computing!