为什么我的azure web角色的启动脚本卡住了?

时间:2014-05-06 03:59:01

标签: com startup azure-web-roles

我试图将我的asp.net应用程序部署到web角色的azure云服务中。我的应用程序引用了第三方遗留组件(32位),这让我头疼不已。由于我只需要一个来自这个组件的dll,我花了很多时间试图找出它的依赖关系,但没有运气。看起来安装组件是我的唯一选择,如果我在VM上手动安装组件,它就可以工作。现在,我试图把它放到web角色的启动脚本中。这是一些代码:

ServiceDefinition.csdef中:

<Startup>
  <Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple" />
</Startup>

STARTUP.CMD:

ECHO Start: %date% %time% >> "%TEMP%\StartupLog.txt" 2>&1

ECHO Enabling 32 bit app on win64 >> "%TEMP%\StartupLog.txt" 2>&1
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true >> "%TEMP%\StartupLog.txt" 2>&1

ECHO Installing NET 3.5 >> "%TEMP%\StartupLog.txt" 2>&1
powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Net-Framework-Core" >> "%TEMP%\StartupLog.txt" 2>&1

IF EXIST "%RoleRoot%\Foundation_Installed.txt" (
ECHO Foundation is already installed. Exiting. >> "%TEMP%\StartupLog.txt" 2>&1
GOTO AfterAppInstall
)

ECHO Start installing Foundation at: %date% %time% >> "%TEMP%\StartupLog.txt" 2>&1
InstallFoundation.exe >> "%TEMP%\StartupLog.txt" 2>&1
ECHO Finished installing Foundation at: %date% %time% >> "%TEMP%\StartupLog.txt" 2>&1

IF %ERRORLEVEL% EQU 0 (
  REM   The application installed without error. Create a file to indicate that the application 
  REM   does not need to be installed again.

  ECHO This line will create a file to indicate that Foundation installed correctly. > "%RoleRoot%\Foundation_Installed.txt"
  ECHO Restarting virtual machine.
  powershell -ExecutionPolicy Unrestricted -command "Restart-AzureVM -ServiceName $cloudSvcName -Name $vmname" >> "%TEMP%\StartupLog.txt" 2>&1

) ELSE (
  REM   An error occurred. Log the error and exit with the error code.

  DATE /T >> "%TEMP%\StartupLog.txt" 2>&1
  TIME /T >> "%TEMP%\StartupLog.txt" 2>&1
  ECHO  An error occurred installing Foundation. Errorlevel = %ERRORLEVEL%. >> "%TEMP%\StartupLog.txt" 2>&1

  EXIT %ERRORLEVEL%
)

:AfterAppInstall

ECHO End: %date% %time% >> "%TEMP%\StartupLog.txt" 2>&1
EXIT /B 0

StartupLog.txt,VM上的日志文件如下所示:

Start: Tue 05/06/2014  3:04:04.36 
Enabling 32 bit app on win64 
Applied configuration changes to section "system.applicationHost/applicationPools" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
Installing NET 3.5 

Success Restart Needed Exit Code      Feature Result                           
------- -------------- ---------      --------------                           
True    No             NoChangeNeeded {}                                       


Start installing Foundation at: Tue 05/06/2014  3:04:10.96 

因此,它在运行InstallFoundation时遇到困难。云服务中的部署成功,但实例遇到状态

  

忙碌(等待角色启动...应用程序启动任务是   运行。 [2014-05-06T03:04:04Z])

使用AutoIT创建InstallFoundation.exe以静默方式运行安装。在VM命令窗口中,我可以成功运行它并正常结束安装。

那么,它是如何被卡在那里的?我错过了一些特权设置吗?命令窗口和Web角色启动任务之间有什么区别?

0 个答案:

没有答案