Start, Restart and Stop Azure VM from Azure CLI (2024)

Start, Restart and Stop Azure VM from Azure CLI (1)

Start, Restart and Stop Azure VM from Azure CLI (2)

Emanuele Bartolesi

Posted on • Updated on

Start, Restart and Stop Azure VM from Azure CLI (3) Start, Restart and Stop Azure VM from Azure CLI (4) Start, Restart and Stop Azure VM from Azure CLI (5) Start, Restart and Stop Azure VM from Azure CLI (6) Start, Restart and Stop Azure VM from Azure CLI (7)

As a developer sometimes I have to use several virtual machines to develop my projects.
My machines, of course, live and run on Azure.
Every time I have to log in on Azure Portal, find the resource group, find the VM, click on "Start" and wait a few minutes to connect to my VM.

The best solution I found is using Azure CLI.

Install Azure CLI

The Azure CLI is a command-line tool for managing Azure resources from Windows, Mac and Linux (Docker, WSL as well).

The current version is 2.0.76.

Install on Windows

To install Azure CLI on Windows is very easy.
You can use this link to download the installer or you can launch this PowerShell script with administrator rights:

Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'

Install on Mac

To install Azure CLI on Mac, you need homebrew.
From a terminal you can launch this command:

brew update && brew install azure-cli

Install on others OS

You can find the full list of supported platform here: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli

Check the installation

To check if Azure CLI is running and the version, you can use this command from a terminal.

az --version

At the moment my favorite terminal app is Windows Terminal

Sign in

The login command is

az login

This is an interactive method and you have to open a browser and navigate to this url: https://aka.ms/devicelogin.
Enter the authorization code displayed in the terminal and then the credentials for your Azure Tenant.
In the next terminal session you can use this tenant or you can add more tenants.
I like this feature.

Start a VM

To start a VM you can use the command below:

az vm start -g MyResourceGroup -n MyVm

You have to change the parameter -g (or --resource-group) with your value.
Same for -n (or --name) with the name of your VM.

You can start all VMs in a resource group with the command below.

az vm start --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)

If you don't want to wait the end of the operation, you can add the parameter --no-wait to your commands.

Stop a VM

Command is very similar to the start command:

az vm stop -g MyResourceGroup -n MyVm

Restart a VM

Same for the restarting command

az vm restart -g MyResourceGroup -n MyVm

Conclusion

With Azure CLI you can manage all resources in Azure and you can do it with cross-platform experience.
You can find the full documentation here: https://docs.microsoft.com/en-us/cli/azure

Top comments (0)

Subscribe

For further actions, you may consider blocking this person and/or reporting abuse

Start, Restart and Stop Azure VM from Azure CLI (2024)
Top Articles
So kannst du deine Schulden abbauen | Clever Finance Girls
Frugal Ways to Save Money in Your Bathroom
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 6156

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.