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?
As you are aware, the 230 seconds is a timeout configured at the Azure App service load balancer. This is a part of the Azure App service architecture and cannot be configured or changed.
Note that the idle timeout is at the TCP level which means that if the connection is idle only and no data transfer happening, then this timeout is hit. --Timeout will hit if the web application got the request and kept processing the request for > 4minutes without sending any data back.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With