1

I'm following these instructions to add IP restrictions to an Azure web role, but I'm not able to change the build action "copy to output directory" property for the startup.cmd script. It's grayed out not available. Can anyone explain why this is? Visual Studio 2013 with Kentico application.

Update 1 - screenshots added

enter image description here

enter image description here

Update 2 - realised I needed to change the "copy to output directory", not build action. Question updated above.

2
  • are you sure you use Web Role and not Web Site ?
    – astaykov
    Mar 5, 2015 at 23:31
  • @astaykov I've added screenshots. Haven't tried this before so I may have done something wrong, but I don't believe so. Mar 6, 2015 at 9:05

1 Answer 1

2

Hm, never tired it before, I always have my startup scripts in my main project. However with this setup, your startup script will be copied automatically to the Approot of the role. That's why no "Copy to output directory".

If we take a closer look to Define Startup Tasks for a Role, we will see a note:

The commandLine task is relative to the AppRoot\Bin folder for the deployment. Environment variables are not expanded in the commandLine value. If environment expansion is required, you can create a small .cmd script that calls your startup task as cmd.exe, which expands the environment variables.

Following that note, the Commandline for your script could look something like:

   <WebRole name="CMSApp">
      <Startup>
         <Task commandLine="..\startup\Startup.cmd" >
         </Task>
      </Startup>
      ....
   </WebRole>

And this should work. Because your content, as defined by the screenshot is in AppRoot\Startup\startup.cmd. However I have not tested it personally.

2
  • This would appear to be the answer, thank you. However, when I deploy to Azure my web role instance becomes stuck on "Busy (Waiting for role to start... System startup tasks are running." and the Visual Studio Azure activity log reports an error "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." Any ideas? Mar 6, 2015 at 10:48
  • 1
    There are two possible reasons for that: (1) Your startup task is returning exit code different from 0 (check this Best Practices tutorial: msdn.microsoft.com/en-us/library/azure/… ) (2) Your startup task pass, but a code in your RoleEntryPoint (if you have) throws Exception, or exits immediately the Run method - check out these two resources: msdn.microsoft.com/en-us/library/… and msdn.microsoft.com/en-us/library/azure/hh771389.aspx
    – astaykov
    Mar 6, 2015 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.