Pre-Role Startup Tasks for Windows Azure
Join the DZone community and get the full member experience.Join For Free
Imagine you need to boot up a web role in the cloud, but before the global.asax events kick in or even lower, before the WebRoleEntryPoint events kick in, you need to do some installations of prerequisite software.
The best way to go about doing this is to register a task in the ServiceDefinition.csdef file. Lets imagine we need to run a batch file that will do some sort of installation, say a monitoring service that is required to be installed BEFORE IIS starts our web application, so that it can get a hook point, say New Relic!
Below is a configuration example that will do this for you.
You can also set elevation privileges, which are required if you are running PowerShell scripts etc.
Task commandLine="Startup.cmd" executionContext="elevated" taskType="background"
You can read more about this here:
So, I hope you now have a cool way to bootstrap your prerequisite software before IIS kicks in.
Published at DZone with permission of Romiko Derbynew, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.