简体   繁体   中英

Powershell cmdlet to gracefully shutdown azure virtual machine

I am having questions around the "Stop-AzureRmVm" PowerShell cmdlet. Does the cmdlet power crash the virtual machines? I have few SharePoint and SQL servers used in our non-production environment. I have powershell scripts that do a scheduled stop and start of these virtual machines.

I am worried if the "Stop-AzureRmVm" PowerShell cmdlet power crashes the virtual machines, as I need the servers to gracefully shutdown.

OR do we have any PowerShell cmdlet that gracefully shuts down the Azure virtual machine?

As long as you are not sending the -force parameter, Azure will attempt to gracefully shutdown the guest OS before stopping. If that doesn't work, the -force parameter is akin to "pulling the plug".

Dont worry, the command Stop-AzureRmVm will gracefully shut down the VM.

If you catch the request of the Stop-AzureRmVm and the Stop option of the VM in the portal, you will find essentially they all call the Virtual Machines - Deallocate REST API, it means if you use the powershell command, it is no difference with that in the portal.

Sorry to revive an old question, but Ken W's accepted answer here is not accurate. The -Force parameter only prevents a Yes/No prompt when running the cmdlet (this is useful for when running in an automated script which cannot accept user input). Either way, running Stop-AzureRmVm will always attempt a graceful shutdown.

The newer 'Az' version of this cmdlet (Stop-AzVM) does have a -SkipShutdown option which will skip any attempt at a graceful shutdown, and will immediately deallocate the VM. More details can be found in the following link:

https://docs.microsoft.com/en-us/powershell/module/az.compute/stop-azvm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM