How do I know whether my Azure role was shut down

2019-09-06 15:36发布

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?

标签: azure cloud
1条回答
地球回转人心会变
2楼-- · 2019-09-06 16:19

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:

  1. Someone logged in via RDP and literally rebooted. No way to track that one. Turn off RDP if you are worried about that being a common scenario. I am not sure OnStop would even be called here.
  2. The fabric controller shuts down the instance to a.) patch the guest OS if allowed (specifying * as guest OS version) or b.) patch the root OS occasionally. You can most likely track this from looking at the infrastructure logs. Setup diagnostics to watch and transfer those logs. I have not personally tried this, but it would be my best guess to tie it together.
  3. Someone hit 'Reboot' from portal or API. There is a List Operations history API call that you can check that will tell you which LiveID or certificate called the Reboot instance API.

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.

查看更多
登录 后发表回答