Azure Virtual Machines
Launch a Linux server on Azure — the same idea as EC2, the Azure way.
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 an Azure Linux VM with the CLI
- Understand VM sizes and images
- Connect via SSH
- Manage and de-provision the VM to control cost
Create a VM in One Command
Azure can create the VM, its disk, network, and public IP in a single command:
az vm create \
--resource-group rg-devops-lab \
--name vm-linux-01 \
--image Ubuntu2404 \
--size Standard_B1s \
--admin-username azureuser \
--generate-ssh-keysNote 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:
ssh azureuser@20.61.45.12Everything 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:
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)
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
- In
rg-devops-lab, create an UbuntuStandard_B1sVM with generated SSH keys. - Note the public IP and connect via SSH; run
uname -a. - Open port 80.
- When finished, deallocate the VM — or delete the whole resource group to clean up completely.
🧠 Knowledge Check
On Azure, which action actually stops you being billed for VM compute?
What is an Azure Network Security Group (NSG) most similar to in AWS?
💼 Interview Preparation
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.