Does Azure role need to clean up local resources before terminating?

只愿长相守 提交于 2019-12-11 07:27:36

问题


Suppose my Azure role is notified that it will be terminated soon and technically can clean up local resources after itself (temporary files for example). Should it do so?

I'm not asking about whether someone will see my leftover temporary files - just how my role can be a polite good Azure citizen.

Does it make sense for the role to clean up local resources or should it just leave everything as is?


回答1:


Like Stuart said, there's no reason to do any local storage cleanup. You either leave it for yourself to use in the future (which is not guaranteed), or you have the local storage cleaned up automatically after your role instance shuts down.

What you do want to do during shutdown is relesae blob leases, close open sessions, shut down database connections, etc. You won't have this opportunity if the Guest OS (or Host OS) crashes, but you always want to handle graceful shutdowns when possible.




回答2:


I can't think of any good reason why you should clean up things like temporary files during this shutdown.

Instead I just use the notification as a graceful way to shutdown - hopefully avoiding leaving any jobs "half-finished".

For the issue of temporary files in particular, the LocalStorage feature has a "Clean on Role Recycle" property - you should probably set that to true.



来源:https://stackoverflow.com/questions/6303063/does-azure-role-need-to-clean-up-local-resources-before-terminating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!