I've deployed an Azure service - once in a while I see in my logs that OnStop()
is called, then after about 20 minutes OnStart()
is called. I'd like to know why that's happening.
How can I know whether my role is restarted manually or by Azure runtime?
Can you explain what you mean by restarted manually? Is that someone logging in via RDP and hitting reboot?
You only have a few options that can trigger a reboot:
So, if you see a OnStop, there is not much you can do about #1 short of turning off RDP (and as I said, I am not sure it would even trigger a OnStop). You can otherwise look to the infrastructure logs and List Operations API to see what initiated it.