3

I have a working deployment. I've added to the configuration file of a Cloud Service Role:

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

Then in the cmd file:

%windir%\system32\inetsrv\appcmd set config /section:urlCompression /doDynamicCompression:True /commit:apphost
%windir%\system32\inetsrv\appcmd set config  -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost

When publishing this to Azure I am getting:

Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation.

the Cmd file has COPY ALWAYS attribute. so this should be fine. When removing the <Startup> tag from the configuration it is successful.

the above seems to fail the deployment

what can be the reason for this? Thanks!

Himberjack
  • 5,682
  • 18
  • 71
  • 115

1 Answers1

4

Ensure the return code of the startup command is always zero, otherwise azure assumes it failed and recycles your role.

You can add 'exit 0' as the last command to your batch file to ensure it exits with a success code of zero.

Most likely, the command is failing, or, it does succeed, but the return code is non-zero to signal nothing changed etc

Andrew
  • 1,606
  • 1
  • 12
  • 19
  • But it does not solve the issue it basically hiding the cause of a problem. is it really right to add "exit 0" in the end. – loop Aug 22 '14 at 13:16
  • @loop sometimes it is suitable. For example, in the above scenario an exit code by appcmd can be non-zero which means "This configuration setting was already applied" so you can just ignore it. The "exit 0" suppresses this code. – Andrew Aug 24 '14 at 02:31
  • @but it may happen that configuration settings are wrong then in that case we just hide the error. It was Happened with me. – loop Aug 24 '14 at 02:34