Azure Cloud Service预热IIS

时间:2016-04-05 16:49:03

标签: azure iis visual-studio-2015 azure-cloud-services

提到这个question我试图在我的WebRole.OnStart中写下这个例子而且我一直得到以下内容

  

详细信息:角色遇到错误并已停止。未处理的异常:System.Net.WebException,Details:Exception:底层连接已关闭:发送时发生意外错误。      在System.Net.HttpWebRequest.GetResponse()      在

并且发布日志指定IISConfigurator启动任务尚未运行 有没有其他解决方案

我正在使用

  • cloud-service classic
  • azure API 2.8.2
  • Visual Studio 2015 Update 1

1 个答案:

答案 0 :(得分:1)

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

以下是您作为ServiceDefinition.csdef中的站点的兄弟添加到WebRole的Startup节点。还包括如何注入可以通过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>

相关问题