Azure 云服务预热 IIS

Azure Cloud Service warmup IIS

参考这个 question 我试图在我的 WebRole.OnStart 中写那个例子,我不断得到以下内容

Details: Role has encountered an error and has stopped. Unhandled Exception: System.Net.WebException, Details: Exception: The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.GetResponse() at

并且由于发布日志指定 IISConfigurator 启动任务尚未 运行 有没有其他解决办法

我正在使用

您可以在主机 VM 启动时执行脚本,方法是将脚本包含在项目中并将启动任务添加到 ServiceDefinition.csdef。在下面的示例中,我们 运行 Startup.cmd。我们使用它通过从脚本中调用 appcmd.exe 来为我们的站点禁用 idleTimeout。

下面是您作为 ServiceDefinition.csdef 中站点的同级添加到 WebRole 的启动节点。还包括如何注入 运行 可通过 RoleEntryPoint 访问的时间变量,关于 RoleEntryPoint here.

的精彩文章
 <Startup>
  <Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple">
    <Environment>
      <Variable name="isEmulated">
        <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
      </Variable>
 <Variable name="instanceId">
        <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/@id" />
      </Variable>
    <Environment>
</Task>