我一直在观看有关构建会议的一些视频:Inside Windows Azure 等。
我从其中的一个收获是,除非我将预配置的 VHD 加载到虚拟机角色中,否则如果实例被关闭或回收,我可能会丢失任何系统设置。
例如,我有一个帐户,有 2 个 Web 角色,运行多个(小型)网站。为了实现这一点,我必须调整主机文件中的设置。我知道我的网站在发生故障时将被延续,因为它们是在 ServiceConfiguration.csfg 中定义的,但如果发生故障,我的主机文件设置是否也会延续到新实例?
即我的网络角色“模板”有多深/全面?
I've been watching some videos from the build conference re: Inside Windows Azure etc.
My take away from one of them was that unless I loaded in a preconfigured VHD into a virtual machine role, I would lose any system settings that I might have made should the instance be brought down or recycled.
So for instance, I have a single account with 2 Web Roles running multiple (small) websites. To make that happen I had to adjust the settings in the Hosts file. I know my websites will be carried over in the event of failure because they are defined in the ServiceConfiguration.csfg but will my hosts file settings also carry over to a fresh instance in the event of a failure?
i.e. how deep/comprehensive is my "template" with a web role?
发布评论
评论(3)
hosts
文件将在任何完全重新部署或重新映像时重建。一般来说,您应该避免依赖于对操作系统创建的任何文件的更改。如果您的应用程序迁移到另一台服务器,它将在具有自己的新 Windows 副本的新虚拟机上运行,因此更改会突然消失。
如果执行到 Azure“临时”环境的部署,然后执行“交换 VIP”,也会发生同样的情况:“临时”环境不会对操作系统文件进行更改。
Microsoft 故意不公布 Azure 映像的内部细节,因为它们将来很可能会发生变化,但目前
在完整部署或重新映像中,您会收到一个新的虚拟机,因此所有三个驱动器都会重新创建。升级时,虚拟机继续运行,但负载均衡器会迁移流量,同时将新版本的应用程序部署到驱动器 F:。然后删除驱动器 E:。
因此,直接回答您的问题,“模板”适用于驱动器 E:--其他任何内容都可能在您不知情的情况下发生变化,并且不能依赖。
The
hosts
file will be reconstructed on any full redeployment or reimage.In general, you should avoid relying on changes to any file that is created by the operating system. If your application is migrated to another server it will be running on a new virtual machine with its own new copy of Windows, and so the changes will suddenly appear to have vanished.
The same will happen if you perform a deployment to the Azure "staging" environment and then perform a "swap VIP": the "staging" environment will not have the changes made to the operating system file.
Microsoft intentionally don't publish inner details of what Azure images look like as they will most likely change in future, but currently
On a full deployment, or a re-image, you receive a new virtual machine so all three drives are re-created. On an upgrade, the virtual machine continues to run but the load balancer migrates traffic away while the new version of the application is deployed to drive F:. Drive E: is then removed.
So, answering your question directly, the "template" is for drive E: -- anything else is subject to change without your knowledge, and can't be relied on.
Azure 提供启动脚本,以便您可以在实例启动时更改配置。这些通常用于安装其他操作系统组件或进行 IIS 配置更改(例如禁用空闲超时)。
请参阅http://blogs.msdn.com/b/lucascan/archive/2011/09/30/using-a-windows-azure-startup-script-to-prevent-your-site-from- being-shutdown.aspx 为例。
Azure provides Startup Scripts so that you can make configuration changes on instance startup. Often these are used to install additional OS components or make IIS-configuration changes (like disabling idle timeouts).
See http://blogs.msdn.com/b/lucascan/archive/2011/09/30/using-a-windows-azure-startup-script-to-prevent-your-site-from-being-shutdown.aspx for an example.
现有答案在技术上是正确的并回答了问题,但在单个 Web 角色中托管多个网站根本不需要编辑主机文件。只需在 ServiceDefinition.csdef 中定义多个网站(具有不同的主机标头)即可。请参阅 http://msdn.microsoft.com/en-us/library/gg433110。 ASPX
The existing answers are technically correct and answer the question, but hosting multiple web sites in a single web role doesn't require editing the hosts file at all. Just define multiple web sites (with different host headers) in your ServiceDefinition.csdef. See http://msdn.microsoft.com/en-us/library/gg433110.aspx