To prevent AppPool recycling every 20 minutes, I'd like to remove IIS AppPool Idle Timeouts when my Azure Web Role starts. My website is a Web Application Project.
How do I do this?
Create a startup task to disable the idle timeout:
In the website project referenced by your web role project, add a file Startup.cmd
to the root folder.
In the properties for Startup.cmd
, set Copy to Output Directory to Copy if newer.
Add this line to Startup.cmd
:
if exist %windir%\system32\inetsrv\appcmd.exe %windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00
The if exist %windir%\system32\inetsrv\appcmd.exe
qualifier is optional. It lets you use the same code on the Azure Emulator Express, so you don't need IIS installed or need to run Visual Studio as Administrator.
Save the file as UTF-8 without signature. (File > Advanced Save Options in Visual Studio.)
In your web role project, in ServiceDefinition.csdef
, add this to the WebRole
:
<Startup>
<Task commandLine="Startup.cmd" executionContext="elevated" />
</Startup>