[英]Powershell cmdlet to gracefully shutdown azure virtual machine
I am having questions around the "Stop-AzureRmVm" PowerShell cmdlet.我对“Stop-AzureRmVm”PowerShell cmdlet 有疑问。 Does the cmdlet power crash the virtual machines?
cmdlet 电源是否会使虚拟机崩溃? I have few SharePoint and SQL servers used in our non-production environment.
我在非生产环境中使用的 SharePoint 和 SQL 服务器很少。 I have powershell scripts that do a scheduled stop and start of these virtual machines.
我有 powershell 脚本,可以按计划停止和启动这些虚拟机。
I am worried if the "Stop-AzureRmVm" PowerShell cmdlet power crashes the virtual machines, as I need the servers to gracefully shutdown.我担心“Stop-AzureRmVm”PowerShell cmdlet 电源是否会使虚拟机崩溃,因为我需要服务器正常关闭。
OR do we have any PowerShell cmdlet that gracefully shuts down the Azure virtual machine?或者我们是否有任何可以正常关闭 Azure 虚拟机的 PowerShell cmdlet?
As long as you are not sending the -force
parameter, Azure will attempt to gracefully shutdown the guest OS before stopping.只要不发送
-force
参数,Azure 就会在停止之前尝试正常关闭来宾操作系统。 If that doesn't work, the -force
parameter is akin to "pulling the plug".如果这不起作用,则
-force
参数类似于“拔掉插头”。
Dont worry, the command Stop-AzureRmVm
will gracefully shut down the VM.别担心,命令
Stop-AzureRmVm
会正常关闭 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.如果你在门户中捕捉到
Stop-AzureRmVm
的请求和VM的Stop
选项,你会发现它们本质上都在调用Virtual Machines - Deallocate
REST API,这意味着如果你使用powershell命令,它与在门户中。
Sorry to revive an old question, but Ken W's accepted answer here is not accurate.很抱歉重提一个老问题,但 Ken W 在这里接受的答案不准确。 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).
-Force参数仅防止在运行 cmdlet 时出现是/否提示(这对于在无法接受用户输入的自动化脚本中运行时很有用)。 Either way, running Stop-AzureRmVm will always attempt a graceful shutdown.
无论哪种方式,运行 Stop-AzureRmVm 都将始终尝试正常关闭。
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.此 cmdlet 的较新“Az”版本 (Stop-AzVM) 确实具有-SkipShutdown选项,该选项将跳过任何正常关闭的尝试,并立即解除分配 VM。 More details can be found in the following link:
可以在以下链接中找到更多详细信息:
https://docs.microsoft.com/en-us/powershell/module/az.compute/stop-azvm https://docs.microsoft.com/en-us/powershell/module/az.compute/stop-azvm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.