The fastest way to gain control over your environment is through the Command Line Interface (CLI). In this article, I’m going to show you exactly how to Start and Stop Azure VMs using the Azure CLI like a pro.
Start/Stop VM Using Azure CLI
Understanding the “Stop” vs. “Deallocate” Trap
In Azure, “Stopped” does not always mean “Free.”
| State | Action Trigger | Billing Status | What Happens? |
| Stopped | Shutdown via Guest OS | Incurring Charges | The OS is off, but Azure still reserves the hardware and IP for you. |
| Stopped (Deallocated) | Stopped via CLI/Portal | No Compute Charges | The hardware is released. You only pay for storage (disks). |
Pro Tip: Always stop your VMs via the CLI or Portal to ensure they reach the Deallocated state. If you just remote in and click “Shut Down” inside Windows or Linux, you’re still paying for that compute!
Step 1: Setting Up Your Environment
To follow along, you’ll need the Azure CLI installed on your machine.
- Check your version: Open your terminal and run
az --version. - Login: You must authenticate your session. Run
az login. This will open a browser window; once you sign in with your corporate or personal account, you’re ready. - Set your Subscription: If you have multiple subscriptions (e.g., Pay-As-You-Go and an Enterprise Agreement), make sure you are in the right context:
az account set --subscription "Your-Subscription-Name"
Step 2: Starting an Azure VM via CLI
Starting a VM is the most straightforward operation. This is particularly useful for “warming up” environments before a team starts their workday.
Basic Start Command
To start a specific VM, you need two pie