问题
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