在 Azure 云服务中添加启动任务不会在本地 运行

Adding Startup task in Azure Cloud Service doesn't run locally

我正在向我的 Azure 云服务项目添加一个简单的启动任务。该脚本确保云服务不会在服务器上超时(请参阅 link)。当我将任务添加到我的 ServiceDefinition.csdef 文件时,我的项目没有 运行;它永远挂起并在 VS 的状态栏中读取 "Starting the roles for the application in the Microsoft Azure compute emulator..."。这是我的 ServiceDefinition.csdef:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="DryrunCloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
  <WebRole name="MyCloud" vmsize="Small">
   <Startup>
  <Task commandLine="Startup.cmd" executionContext="limited" taskType="simple"></Task>
</Startup>
<Sites>
...

Startup.cmd文件(放在web角色项目的bin文件夹中):

REM *** Prevent the IIS app pools from shutting down due to being idle.
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -   applicationPoolDefaults.processModel.idleTimeout:00:00:00

REM *** Prevent IIS app pool recycles from recycling on the default schedule of 1740 minutes (29 hours).
 %windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.time:00:00:00

有什么想法吗?

Thislink最终帮助了我。当您在 VS 中创建 cmd 文件时,由于某种原因它不起作用。您必须在解决方案之外创建它,然后将其添加到您的项目中。