There are several reasons why a PaaS cloud service role instance would restart or recycle. This list may not be exhaustive, but I believe it covers all scenarios as of today. Some day when I have free time I will try to edit this blog post to include details about how to detect each of these restarts.
The items at the bottom marked with [VM] will cause a reboot or reimage of the VM itself, while the other items will leave the VM running but cause a restart of the role processes. For more information about the role processes, see https://blogs.msdn.microsoft.com/kwill/2011/05/05/windows-azure-role-architecture/.
- A new version of the Azure Guest Agent
- In place upgrade of the cloud service
- Calling RoleEnvironment.RequestRecycle from within the VM
- Stop/Start management operation
- Setting e.Cancel=true in the RoleEnvironment_Changing event
- The role host process exiting the RoleEntryPoint_Run method
- The role host process crashing
- Host or Guest OS Updates [VM]
- Reboot or Reimage management operation [VM]
- A hardware issue on the physical server causing service healing and node movement [VM]
- A communication failure between the Guest Agent and the Host Agent that lasts longer than 10 minutes [VM]