0

Quick Tip – Easily Start All Azure VMs In A Particular Resource Group

Manually starting up lab VMs is painfully slow, and since many organisations will implement management policy to auutomatically shut them down to save costs you may find yourself powering them on a lot...

While you can set up automated tasks to power them on, not all really need to be running every day.  For example, I always want the DC's running so they are able to maintain replication and there is no additional delay in waiting for them to boot when what I really want to work on is an application server.

Bonus Tip - Make life even simpler when JIT is enabled.

Azure cloud shell can make this task nice and simple!

Azure Cloud Shell is an interactive, authenticated, browser-accessible terminal for managing Azure resources. It provides the flexibility of choosing the shell experience that best suits the way you work, either Bash or PowerShell.  To persist files across sessions, Cloud Shell walks you through attaching an Azure file share on first launch. Once completed, Cloud Shell will automatically attach your storage (mounted as $HOME\clouddrive) for all future sessions. Additionally, your $HOME directory is persisted as an .img in your Azure File share. Files outside of $HOME and machine state aren't persisted across sessions.

Cloud Shell runs on a temporary host provided on a per-session, per-user basis. Your Cloud Shell session times out after 20 minutes without interactive activity. Cloud Shell persists your files in your $HOME location using a 5-GB file share.

Launch Azure Cloud Shell

Start the shell - the icon is indicated by the yellow arrow.

Click To Start Azure Cloud Shell

If this is the first time launching Cloud Shell, you will be prompted to select the storage.  If that was done, the Shell will start and you will see the interface dispalyed in your browser.

In the example below, you can see the regular PowerShell cmdlets.

Get-AzResourceGroup *toys* | Select-Object ResourceGroupName

Azure Cloud Shell Launched - Connected to Home Drive

You can see that there are two resource groups, one for each lab environment.

Commands To Start All VMs In A ResourceGroup

The below commands can be used to start the VMs in a given Resource Group.  Change the Resource Group name to match your environment.

Get-AzVM -ResourceGroupName "Tailspintoys-Canada" | Start-AzVM –NoWait
Get-AzVM -ResourceGroupName "Wingtiptoys-Canada" | Start-AzVM -NoWait

Using Azure Cloud Shell To Easily Start All VMs In A Resource Group

Cheers,
Rhoderick

Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *