Controlling Application Pool Idle Timeouts in Windows Azure
A question I hear from time to time is whether it’s possible to change the idle timeout time for IIS application pools in Windows Azure. It is indeed possible, and fairly easy to do with a startup task.
The default idle timeout value is twenty minutes, which means your app pool is shut down after twenty minutes if it’s not being used. Some people want to change this, because it means their apps are a bit slow after twenty minutes of inactivity.
To change the timeout to zero (which means “never”), add the following startup task declaration to ServiceDefinition.csdef
:
<Startup> <Task commandLine="startup\disableTimeout.cmd" executionContext="elevated" /> </Startup>
And add disableTimeout.cmd
in a folder called startup
, with the following line of code (should be one line, split just for formatting):
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00
Be sure to mark disableTimeout.cmd
’s “Copy to Output Directory” setting to “Copy always”.