DEV Community

Cover image for How to setup a Linux Virtual machine on Azure Portal
Emmanuel Banjo
Emmanuel Banjo

Posted on

How to setup a Linux Virtual machine on Azure Portal

Introduction

I always thought Linux servers were complicated and only for experts. Turns out, setting one up in Azure is pretty straightforward.
This guide shows you exactly how to create a Linux VM in Azure, connect to it from your computer, and run your first commands. No prior Linux experience needed, I also learned as I went!

Step 1: Create a Resource Group

  • In azure portal, search Resource group and hit ENTER!

createrg

  • Click on create button

create

  • Name your resource group
  • Choose your preferred region (choose one closest to you)
  • Click Review and create

review

  • Then click create

createn

Step 2: Start Creating Your Linux VM

  • Go to Azure Portal and search for Virtual machines

search

  • Click + Create → Azure virtual machine

createn

  • Under project details, Select your resource group

rg

Step 3: Configure basic instance details

  • Virtual machine name: Type something like mylinuxvm
  • Region: Pick one close to you
  • Availability options: Choose No infrastructure redundancy required
  • Security type: Standard Image: Choose your Linux flavor: Ubuntu Server 24.04 LTS ← I recommend this for beginners
  • Size: I chose D2s version

instance details

Step 4: Set Up Your Login Method and configure Network Access

Here's where it gets interesting. You have two options:
- SSH Key (More Secure)
- Password (Simpler for first timers)
I went with Password because it's less complicated

  • Create a username (like adminuser)
  • Create a strong password (write it down!)
  • Public inbound ports: Select Allow selected ports
  • Select inbound ports: Choose HTTP (80) and SSH (22)

admin

Step 5: Configure Monitoring, Validate and create

  • Scroll back to the top and choose the Monitoring tab
  • Disable boot diagnostics
  • Click Review and create

Monitoring

  • Your configurations are now Validated and your Virtual machine is ready to come alive, click create

create
Wait 2-3 minutes for deployment, then click Go to resource

created

Step 6: Verify your VM created and Connect

In your Linux VM resource, you would notice the public IP in the overview tab, This is what you would need to connect. Before connecting, we would need to increase the idle time of our virtual machine

  • Click on the Public IP

linux

  • Increase the Idle time to 30 (max), then Apply

idle

  • Back to the overview page, click Connect

connect

  • Check network access, click check access

access

  • Once we verify the connection, then we need to connect to our Linux virtual machine. Copy the SSH command

SSH

  • In your terminal (for macs) or Powershell (windows), paste this SSH command and run. When it runs successfullly, it requests confirmation and ask for your password (remember the password we set in step 4).
  • Enter your password (usually this doesn't show up, so accuracy is important) Your linux VM connection is successful

ubuntu
When operating linux, we need to run commands as a root user or add "sudo" to every command. In order to make commands work smoothly, we can change the user to a root user and update our linux server.

  • run the command "sudo su"
  • run the command "apt update" apt (Advanced Package Tool) is a powerful, interactive command-line utility for managing software on Debian-based Linux distributions, such as Ubuntu and Linux Mint. It handles installation, removal, upgrading, and dependency management of .deb packages by automating retrieval from online repositories.

update

Step 7: Install applications on your server

Now that our linux server is up-to-date, we would proceed with installing some applications. In this exercise, I would be installing Vim and Nginx

  • Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.
  • NGINX is open-source web server software used for reverse proxy, load balancing, and caching
    • Install vim with the command "apt install vim
    • when prompted, confirm with a Y

vim

  • Lastly, install nginx with the command "apt install nginx"
  • When prompted, confirm with Y

nginx

Our linux Virtual machine now has a software installed on it. Let's check it out.

  • Copy the Public IP in Step 6
  • Paste in your browser tab and hit ENTER!

welcome
If everything else is correct, you should be presented with this nice screen here!

You just created and connected to a real Linux server running in Microsoft's datacenter. The same technology that powers Netflix, Spotify, and thousands of companies.
The best part? You can destroy it and create a new one anytime.
Remember: Stop your VM when you're done playing. Future you will appreciate the lower bill!

What did you install on your Linux VM? Share in the comments! And if you got stuck anywhere, let me know; I probably hit the same issue when I started.

Top comments (0)