A practical, beginner-friendly walkthrough of deploying an Azure Virtual Machine, configuring a Virtual Network, SSHing in, and hosting a live Apache2 web server — all from scratch.
TL;DR: In this post, I walk through how I deployed an Azure Virtual Machine from scratch — set up the subscription, resource group, virtual network, and finally spun up an Apache2 web server accessible via a public IP. If you're just getting into cloud engineering, this one's for you.
Why This Matters
Cloud infrastructure isn't just for big tech anymore. Whether you're building a side project, preparing for a cloud cert, or just trying to understand what "the cloud" actually means under the hood — knowing how to spin up a virtual machine and serve traffic from it is a fundamental skill.
This post documents my hands-on journey doing exactly that on Microsoft Azure. Every step is screenshotted, so you can follow along visually.
Let's get into it. 🚀
Prerequisites
Before we dive in, make sure you have:
- An active Microsoft Azure account (free tier works fine to start)
- Git Bash installed (or any terminal that supports SSH)
- Basic comfort with the command line
Step 1: Create a Subscription
Everything on Azure lives under a subscription — think of it as your billing and organizational umbrella.
- In the Azure portal, search for "Subscriptions" in the top search bar and click on it.
- Click Create.
- Type your subscription name in the highlighted field (I named mine My VM & Apache Setup).
- Click Next and follow through each stage.
Once you've gone through all the tabs, you'll land on the Review + Create screen. Confirm the validation passes and hit Create.
💡 If you're on the Azure free tier, a default subscription is usually already set up for you. You can skip this step and move straight to Step 2.
Step 2: Create a Resource Group
A Resource Group is a logical container for all the Azure resources that belong to a project. It keeps things tidy and makes cleanup much easier when you're done.
- From the left-hand menu of your subscription, select Resource Groups, then click Create.
- Enter the required details — your subscription, a region, and a meaningful name for the group. I used
MyVM1-setupand selected (Africa) South Africa North as my region. - Click Next through each section and finalize with Review + Create → Create.
Your Resource Group is now live and ready to house all the resources we'll be creating.
Step 3: Create a Virtual Network (VNet)
The Virtual Network is the private network your VM will operate inside. This is where you define your IP address ranges, subnets, and traffic boundaries. Think of it as building the roads before driving the car.
3a. Create the VNet — Basics Tab
- Search for "Virtual Network" in the search bar and click on it.
- Click Create, then select your subscription and resource group.
- Give your VNet a name and proceed to the next tab.
3b. Security Settings
Leave the defaults in the Security section and click Next — no changes needed here for a basic setup.
3c. Address Space & Subnets
In the Address Space tab, you'll see a default subnet already configured. I deleted it and created my own to have full control over the IP range.
Click Next through Tags (skip if you don't need them), then select Create in the Review + Create tab.
3d. Navigate to Subnets After Deployment
Once the VNet deploys, you'll see the success screen. Click Go to resource.
Then, in the left-hand menu under Settings, click Subnets. Hit the + Subnet button at the top to add a new one.
3e. Add Your Subnet
In the Add a Subnet pane, enter your subnet name and configure the IP address range. I used vm1-subnet with a /24 range (10.0.1.0 - 10.0.1.255 — 256 addresses). Click Add when done.
Step 4: Create the Virtual Machine
Here's where the fun begins. 🎉
- Search for "Virtual Machines" in the portal. You'll see the VM dashboard — currently empty.
- Click Create and fill in all the necessary details — name, region, image (I used Ubuntu 24.04 LTS), size, and disk (I went with a 64 GB Standard SSD).
-
Critical step — Inbound Port Rules: Make sure these two ports are open:
- Port 22 — for SSH access
- Port 80 — for HTTP (public web access)
When you're satisfied with your configuration, click Review + Create → Create.
A prompt will immediately appear asking you to generate and download your SSH key pair. This is non-negotiable — Azure does not store the private key after this point. Download it, keep it safe.
Click Download private key and create resource, then Return to create a virtual machine. Wait a few minutes for the deployment to complete.
Step 5: SSH Into Your VM
With the VM up and running, it's time to connect to it. Open Git Bash and run the following:
# Navigate to your Downloads folder (where your .pem file is)
cd downloads
# Set the correct permissions on your key file (required for SSH)
chmod 400 vm1key.pem
# SSH into the VM using your key, username, and public IP
ssh -i vm1key.pem mrjoe@20.99.232.218
🔁 Replace
vm1key.pemwith your actual key filename andmrjoe@20.99.232.218with your VM's username and public IP address. You'll find the public IP on your VM's overview page in the portal.
You'll be prompted to confirm the host fingerprint — type yes and hit Enter. If the key file and username are correct, you'll be welcomed right in.
Now update the OS to make sure everything is current:
sudo apt update
sudo apt upgrade -y
Then install Apache2:
sudo apt install apache2 -y
Apache2 starts automatically right after installation. No extra configuration needed. ✅
Step 6: Verify Apache in Your Browser — It Works! 🎉
Open any browser and navigate to your VM's public IP over HTTP:
http://20.99.232.218
If everything went smoothly, you'll be greeted by the Apache2 Ubuntu Default Page — the classic "It works!" screen that confirms your web server is live and publicly accessible.
What We Built
Let's quickly recap what was set up end-to-end:
| Component | Purpose |
|---|---|
| Subscription | Billing and organizational container for all Azure resources |
| Resource Group | Logical grouping to manage and clean up project resources |
| Virtual Network + Subnet | Private network environment for the VM to operate in |
| Virtual Machine (Ubuntu 24.04 LTS) | The compute instance running our workload |
| Apache2 | Web server serving HTTP traffic publicly on Port 80 |
Key Takeaways
- Networking matters first. Setting up your VNet and subnets before the VM ensures your machine is dropped into the right network environment from day one.
- Open only the ports you need. Port 22 for SSH and Port 80 for HTTP — nothing more. Security begins at the network layer.
-
Your
.pemfile is your key — literally. Azure will not store it for you. Lose it and you lose SSH access. Treat it like a password. - Apache2 just works. For a quick web server deployment on Ubuntu, it's hard to beat — install, done, live.
What's Next?
This is just the foundation. From here, you could:
- Point a custom domain at your VM's public IP
- Set up HTTPS with Let's Encrypt (free TLS/SSL)
- Deploy a full web application instead of the default Apache page
- Explore Azure Load Balancers to distribute traffic across multiple VMs
- Lock down your VM further with Azure Network Security Groups (NSGs)
The cloud is a lot less intimidating once you've actually deployed something and watched it load in your browser. If you followed along and hit any snags, drop a comment below — happy to help.
Keep building. ☁️
#azure #cloudengineering #devops #linux #apache #virtualmachine #beginners #100daysofcloud

















Top comments (0)