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).