Does SQL server start / stop automatically when virtual machine stops

Swathi K 1 Reputation point
2022-12-01T11:33:42.977+00:00

I'm trying to stop/start virtual machine in azure portal. Does sql server also get stopped/started automatically if virtual machine stopped? If virtual machine stops sql server automatically does it crash the sql server?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,035 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ronen Ariely 15,206 Reputation points
    2022-12-01T12:31:22.167+00:00

    Hi,

    Does sql server also get stopped/started automatically if virtual machine stopped?

    In short, when you shutdown/Restarting the machine in an ordinarily way then SQL Server should be stopped/started normally.

    what happened in the background and what impact it will do when we Turn OFF or reboot the Azure VM from the portal Vs Turn OFF or reboot the VM from the operating system.

    When we control the physical host machine of the VM then we can run Soft Shutdown/Reboot or Hard Shutdown/Reboot. A Soft Shutdown/Reboot action send instruction to the operating system of the VM to initiate a normal shutdown/reboot. In this case, the OS stop the internal services (like SQL Server) in an ordinarily way like we are running shutdown/reboot on physical machine.

    As users in the Azure, we only have option to send a request for "Soft Shutdown/Reboot". If that action instruction to the operating system coming from the host is failed, then it might be to force Hard shutdown/reboot of the VM, but this is not the normal behavior.

    When you stop a VM through Azure portal, Azure PowerShell, command-line interface, or REST API, rather than through the OS, it goes into a “Stopped (deallocated)” state. In this case it is first go through the step of shutdown/reboot the VM in an ordinarily way. It’s a soft shutdown/reboot.

    Note that you can find the event in the Azure Activity Log and You can follow it a bit using the "Boot diagnostics" in the portal while the VM is still shut downing. There you might notice the messages like you see on local machine that you shutdown (for example if the OS doing an update).

    What happen when SQL Server get the command to Shutdown

    https://learn.microsoft.com/en-us/sql/t-sql/language-elements/shutdown-transact-sql?view=sql-server-ver16&WT.mc_id=DP-MVP-5001699


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.