Does Azure role need to clean up local resources before terminating?
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?
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.
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.
精彩评论