4

I have an Azure project with an MVC4 role where I have added the Visual C++ 2012 Runtime Library setup file, and a script to silently install it.

The script works and the library gets installed, the only problem is that the task never finishes and the installation process never exits, which then blocks the role from starting: Role Instance

I connected to the server using Remote Desktop, and by looking at the task manager I can see the process vcredist_x64.exe: (2 of them actually, but I think that's normal)

Windows Server Task Manager

When I right-click and kill the process, the deployment finishes successfully and the role is started.

This is a problem when my start-up task is set to simple in ServiceDefinition.csdef, since that makes the server wait until the task is finished to start the role. So what I did was to set the task to background so the start-up script doesn't block the role from starting anymore, but even then the process is still running in the background and has to be killed manually.

This script should work, and has before with the 2010 VC++ library (Without the EXIT though, but that should be there as to avoid blocking the role if the script returns an error code):

vcredist_x64.exe /quiet /norestart
EXIT /B 0

Didn't work, so I thought I'd kill the process manually after the installation:

vcredist_x64.exe /quiet /norestart
TASKKILL /F /T /IM vcredist_x64.exe
EXIT /B 0

Didn't work, process was still alive. The script actually works if I run it manually myself on the server, or locally, but when Azure tries to do it during deployment it hangs.

My Start-up task is defined like this in ServiceDefinition.csdef:

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

The logs in C:\Resources\temp\{RoleId.RoleName}\RoleTemp say everything went okay.

I can avoid the role from being blocked by setting the startup-task to background instead of simple, but that doesn't really solve the problem. Thanks.

Shahin Dohan
  • 6,149
  • 3
  • 41
  • 58
  • Have you tried running it manually (without the /quiet) from RDP? What happens? Is there an error? – user94559 Aug 31 '12 at 19:23
  • I just get the dialog where I can Repair, Uninstall or Close. The process only hangs when Azure tries to run it while deploying, I will try a few more things here and see what happens. – Shahin Dohan Sep 03 '12 at 08:45
  • 1
    And if you run it with the /quiet, I assume it completes successfully? You may want to try psexec to run as the local system user. See http://blog.smarx.com/posts/windows-azure-startup-tasks-tips-tricks-and-gotchas. – user94559 Sep 03 '12 at 10:43
  • Yes, with /quiet it runs and exits successfully. I tried psexec to run it as SYSTEM and it worked fine. I published the solution to a different service and got the same problem. Something has to be misconfigured in the project, since it apparently works for Ram. I added `echo %ERRORLEVEL% >> c:\tasklog.txt` to the script but it doesn't create the file, only when I run the script manually it does, strange. I'll try to narrow down on the problem. Thanks for the help so far! – Shahin Dohan Sep 03 '12 at 13:13
  • I came across your other post via the one you linked, and read your note at the bottom about changing FamilyOS to 2 and it worked! It's a good thing you pointed it out, thanks :) – Shahin Dohan Sep 03 '12 at 14:22

2 Answers2

1

I figured out why this was happening, thanks to this blog post by Steve Marx.

This problem only occurs in Windows Server 2008 SP2, so I had to change the host to Windows Server 2008 R2.
This can be done by changing osFamily="1" to osFamily="2" in all of the ServiceConfiguration files, or it can be changed from the Azure portal by clicking on the service then Configure OS at the top.

Shahin Dohan
  • 6,149
  • 3
  • 41
  • 58
0

I needed to use this library as well. this is my script:

start /w
cd startup
vcredist_x64.exe /q /norestart

exit /b 0

it's working for me - startup is where i keep the vcredist_x64.exe.

on my servicedefinition file this is the xml line

 <Task commandLine="startup\InstallVcreditst.cmd" executionContext="elevated" taskType="simple" />
Ram Y
  • 1,944
  • 17
  • 23
  • Thanks for the answer, but our scripts are pretty much identical except for the start /w which only spawns a commandline, and it will block the installation on the cloud so it should only be used locally. – Shahin Dohan Sep 03 '12 at 13:15