How to Start and Stop an Azure VM


There are times when a VM needs to be stopped to perform maintenance operations. Afterwards the VM needs to be started. Doing this via the Azure Portal can be time consuming. It is better to automate this.


Azure Powershell can be used to start and stop VMs. The Stop-AzureRmVM cmdlet stops a VM. The Start-AzureRmVM cmdlet starts a VM. These cmdlets can be used in a script that automates maintenance operations on VMs.


Figure 1: Stop-AzureRmVM cmdlet syntax [1].
Parameter Set: ResourceGroupNameParameterSetName
Stop-AzureRmVM `
[-ResourceGroupName] <String> `
[-Name] <String> `
[-Force] `
[-StayProvisioned] `
[ <CommonParameters>]

-Force runs the command without asking for user confirmation.

Figure 2: Start-AzureRmVM cmdlet syntax [2].
Parameter Set: ResourceGroupNameParameterSetName
Start-AzureRmVM `
[-ResourceGroupName] <String> `
[-Name] <String> `
[ <CommonParameters>]

Further Reading

The VM needs to be stopped before calling Update-AzureRmVM to update KeyVault secrets. The VM needs to be started after Update-AzureRmVM finishes.

Installing a certificate from Azure KeyVault into an Azure VM

Works Cited

  1. Stop-AzureRmVM
  2. Start-AzureRmVM

Join the Conversation

1 Comment

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: