Does a WebRole on Windows Azure has to be stateless?

别来无恙 提交于 2020-01-03 02:48:08

问题


I came across an interesting situation. I have rebootet my WebRole through the Dashboard. Once the WebRole was up and running again, I have remote desktoped into the WebRole and discovered that the entire folders of my published site was wiped and replaced with the one from the package. Only the textfiles outside those folders like on the desktop have survived it.

Unless its the entire drive E: that gets wiped and reinstalled when attempting a reboot.

So now my thoughts that since VMs can be restarted due crashes or Microsoft maintenance, we as developers have to make sure that the WebRole is stateless and nothing is saved locally, is this correct?

Many Thanks,


回答1:


The local disk storage of Compute VMs (whether Web Role, Worker Role, or VM Role) is not persistent. It can go away at any time. The data center has the right to move and re-create your VMs whenever it deems it necessary. This could happen in response to a hardware failure, or simply because the data center needs to be reorganized. When this happens, you lose your VM disk files and go back to your deployment image. It is only a matter of time before this happens. This is normal behavior for cloud computing compute instances.

How do you keep your data in the cloud persistent? It's best to use a persistent, managed service such as Windows Azure Storage or SQL Azure database. That gives you storage you can depend on, backed by triple redundancy.

If you are unable to to move to persistent storage, another approach that may work (if the data files are read-only) is to add the data files to your deployment package and upgrade your VM instances with the package.

this answer has been ported from this URL: http://social.msdn.microsoft.com/Forums/en-AU/windowsazuredevelopment/thread/3cd21ac6-aeb6-442b-af89-ae913946b3ba



来源:https://stackoverflow.com/questions/8517990/does-a-webrole-on-windows-azure-has-to-be-stateless

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