← Back to Home
🖥️

Azure Virtual Machines

Launch a Linux server on Azure — the same idea as EC2, the Azure way.

12 min read📚DevOps Fundamentals

An Azure Virtual Machine (VM) is an on-demand server in Microsoft’s cloud — Azure’s equivalent of AWS EC2. In this lesson you’ll create one, connect with SSH, and manage its lifecycle, tying together everything from the Linux, GitHub, and AWS sections.


🎯 Learning Objectives

By the end of this lesson you will:


Create a VM in One Command

Azure can create the VM, its disk, network, and public IP in a single command:

bash
az vm create \
--resource-group rg-devops-lab \
--name vm-linux-01 \
--image Ubuntu2404 \
--size Standard_B1s \
--admin-username azureuser \
--generate-ssh-keys
bash — 80×24
student@devops:~$az vm create ... --output table

Note the public IP — you’ll use it to connect. Standard_B1s is a small, low-cost size ideal for learning.


Connect with SSH

Because you used --generate-ssh-keys, Azure created a key pair for you. Connect exactly like any Linux server:

bash
ssh azureuser@20.61.45.12
bash — 80×24
student@devops:~$ssh azureuser@20.61.45.12 'uname -a'

Everything you learned in the Linux section now applies to this cloud server.


Open a Port (Network Security Group)

Like AWS security groups, Azure uses Network Security Groups (NSGs). To let web traffic in:

bash
az vm open-port \
--resource-group rg-devops-lab \
--name vm-linux-01 \
--port 80

⚠ Only open what you need

Every open port is an attack surface. Open 80/443 for a web server, keep SSH (22) restricted to your own IP, and close everything else. This is the same discipline you used with AWS security groups.


Manage the Lifecycle (and the Bill)

bash
az vm stop        -g rg-devops-lab -n vm-linux-01   # stop the OS
az vm deallocate  -g rg-devops-lab -n vm-linux-01   # release compute (stops billing)
az vm start       -g rg-devops-lab -n vm-linux-01   # start again

⚠ Stop is not enough — deallocate

On Azure, stop alone can still incur compute charges. Use deallocate to actually release the compute resources and stop the meter. Or, to remove everything at once, delete the whole resource group (previous lesson).


🧪 Hands-on Lab

📝

Deploy and Tear Down a VM

  1. In rg-devops-lab, create an Ubuntu Standard_B1s VM with generated SSH keys.
  2. Note the public IP and connect via SSH; run uname -a.
  3. Open port 80.
  4. When finished, deallocate the VM — or delete the whole resource group to clean up completely.

🧠 Knowledge Check

Knowledge Check

On Azure, which action actually stops you being billed for VM compute?

Knowledge Check

What is an Azure Network Security Group (NSG) most similar to in AWS?


💼 Interview Preparation

Interview Q&A

A teammate says their Azure bill is high even though all their VMs are 'stopped'. What might be wrong?


Summary

You’ve now provisioned, secured, connected to, and de-provisioned an Azure VM — tying together Linux, Git, cloud, and cost management. Next, we automate the configuration of servers like this one with Ansible.

💡 Keep practising

The fastest way to make this stick: pick one small project, put it in GitHub, deploy it to an AWS EC2 or Azure VM, and automate the deploy with a Bash script. Real repetition beats re-reading every time.

Up Next

Introduction to Ansible

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson