Reputation: 907
referring to this question i've tried to write that example in my WebRole.OnStart
and I keep getting the following
Details: Role has encountered an error and has stopped. Unhandled Exception: System.Net.WebException, Details: Exception: The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.GetResponse() at
and as the publish log specifies the IISConfigurator startup task didn't run yet is there any other solution
i'm using
Upvotes: 0
Views: 257
Reputation: 1651
You can execute a script when the host VM starts by including the script in your project and adding a startup task to the ServiceDefinition.csdef. In the example below we run Startup.cmd. We use this to disable idleTimeout for our site by calling appcmd.exe from within the script.
Below is the Startup node you add to WebRole as a sibling to Sites in ServiceDefinition.csdef. Also included is how to inject runtime variables that can be accessed via RoleEntryPoint, great article on RoleEntryPoint here.
<Startup>
<Task commandLine="Startup.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="isEmulated">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
</Variable>
<Variable name="instanceId">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/@id" />
</Variable>
<Environment>
</Task>
Upvotes: 1