Deploying My First Ubuntu Virtual Machine on Microsoft Azure: SSH Access, Apache2 Installation, and Web Server Configuration

Deploying My First Ubuntu Virtual Machine on Microsoft Azure: SSH Access, Apache2 Installation, and Web Server Configuration"

calendar_today agoschedule7 min read
— Originally published at dev.to

Introduction

Microsoft Azure Virtual Machines (VMs) provide scalable cloud computing resources that allow users to deploy and manage operating systems in the cloud. In this project, I created an Ubuntu 22.04 Virtual Machine in Azure, connected to it using SSH from both Git Bash through the Visual Studio Code, updated the server, installed Apache2, configured network security settings, and deployed a custom web page accessible through a public IP address.

This hands-on lab helped me gain practical experience with Azure Infrastructure as a Service (IaaS), Linux administration, SSH connectivity, and web server deployment.

Project Objectives
Create an Ubuntu 22.04 Azure VM
Download and secure a .pem private key
Connect to the VM using Git Bash
Update and upgrade Ubuntu packages
Install and verify Apache2
Create a custom web page
Access the website through a browser

Prerequisites
Active Azure Subscription
Azure Portal access
Git Bash installed
Internet connection

Step 1. Log In to Azure Portal

On your web browser, head over to https://portal.azure.com and log in with your Microsoft account. If you don't have an account, create or sign up and provide the required information so your Microsoft account can be activated.

Image description

A successful login bring you to this page below,
Image description
__Step 2: Create a Resources Group
__

We need to create our Resources Group first before we go ahead to create our virtual machine
. Search for Resource Group in the search bar at the top of your portal

page and Select/Click on Resource Group.

Image description

Click on Create to create Resource Group

Image description

  • Type the Resource group name, select the region and click Next
    Image description

  • Apply tags to your resources to logically organize them by categories and click Next
    Image description
    Review the resources group and click on Create

Image description
Click on Resource Group on the left to bring out the resource group you created

Image description

Step 2. Create a New Virtual Machine
Type "Virtual Machines" in the search bar at the top. Once you see virtual machine display click on the virtual machine

Image description

Once you click on the virtual machine, your screen will be displayed as shown below. Click on CREATE

Image description

When you click on "Create" button, it will display a drop down as shown below. You will then click on the Azure virtual machine highlighted in red arrow. This will take you to the project details where you will begin to fill the basic configuration for you to start creating your virtual machine.

Image description
Create virtual Machine under the BASIC CONFIGURATIONS by filling the following tabs as follows:

_Subscription: Select your subscription(Azure Subscription 1)
Resource Group: Use an existing or create a resource group (FlackernProj-rg)
Virtual machine name: flackern-vm or use your desired username
Region: Select a nearby or preferred location ((Africa) South Africa North)
Availability options: Leave it as default (Availability Zone)
Availability Zone: Zone 1 (For this demo we select only one zone)
Security type: Standard
Image: Ubuntu Server 24.04 LTS - x64 Gen2
VM architecture: x64
Size: Standard_B2as_v2 - 2 vcpus, 8 GiB memory ($71.32)
Authentication type: SSH public key
Username: Use your desired username
SSH public key source: Generate new key pair
SSH Key Type: RSA SSH Format
Key pair name: flackern-vmkey or use your desired username
Public inbound ports: Allow selected ports
Select inbound ports: HTTP (80) and SSH (22)

Image description

Image description

Image description

Image description

Image description

Image description

Step 3. Configure Disks

Click on Next : Disks >, this leads you to on the next page, you can use the default OS disk size, use the Image default (30 GiB) and for the OS disk type, use the default settings Premium SSD (locally-redundant storage) unless you have unique configuration requirements.

Image description

Image description

Step 4. Networking Configuration

On the bottom of the last page in Step 3, Click on Next : Networking >, this leads you to the Network interface page below:

  • Create your virtual network and subnet or make use of the one you have created before

Image description

Image description

Management, monitoring, Advanced, Tags: These pages usually displayed as default. Find their default screenshots below. However, you may wish to skip them and proceed to “Review+Create”.

Image description

Image description

Image description

Image description

Step 5. Generate SSH private Key
After a successful Linux VM deployment process, Azure will validate the configuration

_Then Click "Review + create". This will show validation passed as highlighted below.

Image description

_Then click “Create” . This will take you to the next page to generate new key pair. Then, you will click on “Download private key and create resource” as shown below. The new key pair will then be downloaded on your PC, while Azure will also provision your VM.
__

Image description
Download private key and create resource, afterwards, the deployment will start.

Wait for Deployment: Azure will now provision your virtual machine. This process may take a few minutes. Then the next page will show that your deployment is complete as shown below, then you will click on “Go to Resource”

Image description

Next, click on “Connect” and then “Connect”. This will take you to a page with other options to connect your VM.

Image description

Retrieve Public IP Address: Once the virtual machine is deployed, note down the Public IP address on Azure portal overview page.

Note: Also go to your download and save the downloaded key pair into a file for later use when connecting via SSH.

Step 6: SSH into VM Using Git Bash -Connect via SSH Key Authentication:
Open your Command Line Interface on Windows or Terminal on your Visual studio code using gitbash or power shell
Move the .pem file into a secure folder.
Set permissions:
chmod 600 flackern-vm_key.pem

Image description

Step 7: SSH into VM Using Azure Cloud Shell
Connect:
ssh -i flackern-vm_key.pem flackern-vm@102.37.144.183
Image description

Step 8: Update Ubuntu Packages
Using sudo apt update and click enter.This will update our virtual machine

Image description

Step 9: Install Apache2
Instal apache2 on our VM and click enter
Install:
sudo apt install apache2 -y

Image description

Now let us confirm if apache2! Was actually installed on the virtual machine, we can do this by going to your Azure site and copy the ip address and paste it on the web page and see the result.

Copy ip address
Image description

Test Your Web Server
Open a web browser and enter the public IP address you obtained earlier. If apache2 is running correctly, you should see a default welcome page.
Congratulations! You have successfully created a Linux virtual machine on Microsoft Azure and installed the Apache2 web server. This is a foundational step for hosting web applications or deploying other web services.

Image description

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Implementing Cellular Redundancy: Cross-Cloud Failover with AWS Transit Gateway and Azure ExpressRou

Cláudio Raposo - May 5

Local-First: The Browser as the Vault

Pocket Portfolio - Apr 20

How to create a Virtual Machine in Microsoft Azure.

NURUDEEN ADEWALE - Jul 27, 2025

I Aliased 'syscheck' to 7 Lines of Bash and Now I Run It on Every Server I SSH Into

BashSnippets - May 31

Implementing Cellular Data Sovereignty: AWS DynamoDB Global Tables vs. Azure Cosmos DB Multi-Region

Cláudio Raposo - May 7
chevron_left
141 Points2 Badges
2Posts
0Comments
Olakunle Makanjuola

Data Analyst | Power BI | SQL | Python | Cloud Computing & DevOps Engineer in P... Show more

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!