Deploy Linux VM with Networking using Azure CLI Script
Automate Azure infrastructure deployment with Bash scripting. Create a reusable script to deploy a Linux VM with networking using Azure CLI commands.

Lab overview
Azure CLI is a command-line tool for managing Azure resources on Windows, macOS, and Linux. Combined with Bash scripting, it lets you automate infrastructure deployments so the same commands run the same way every time. Teams use this pattern to reduce manual errors and to practice Infrastructure as Code without jumping straight to ARM or Bicep.
A Bash script packages those CLI commands into one file: argument checks, resource lookups with JMESPath, and a Linux VM with VNet, subnet, NSG, public IP, and NIC created in a single run.
In this lab, you will write deploy.sh, run it against your lab resource group, and SSH into the Linux VM it creates.
Objectives
By completing this intermediate lab, you will be able to:
- Build a reusable Bash script that deploys Azure resources with Azure CLI
- Validate script arguments and test that a resource group exists before deploying
- Capture Azure CLI output with command substitution and JMESPath queries
- Deploy a Linux VM with VNet, subnet, NSG, public IP, and NIC
- Configure SSH key authentication for the VM
Who is this lab for?
This lab is designed for:
- Cloud Engineers who need to automate Azure deployments with scripting
- DevOps Engineers looking to practice Infrastructure as Code with Azure CLI
- System Administrators transitioning to cloud-based automation
You should already be comfortable with a Bash terminal and with signing in through Azure CLI.
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.
More labs like this
Managing Azure Blob Storage Operations with Azure CLI
Learn how to perform essential Azure Blob Storage operations using Azure CLI commands. Practice uploading, downloading, listing, and deleting blobs with batch operations.
Deploying a Linux VM with Networking using Azure PowerShell
Deploy a Linux VM with networking using Azure PowerShell. Learn cmdlets, variables, and pipelines while creating NSGs, VNets, and NICs in Cloud Shell.
Azure CLI Essentials: Managing Azure Resources with Command Line Tools
Master Azure CLI essentials by managing resource groups, deploying container apps and VMs, and managing resource states in this hands-on lab.
Related reading
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Logging into Azure CLI
- 02
Writing a Bash Script to Deploy a Linux VM
1 automated check
- 03
Running the Linux VM Script and Connecting with SSH
1 automated check
Skills validated
Not the lab you were looking for?
Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.