Iis – Automate app pool recycling of an Azure Cloud Service Web Role

application-poolsazureiispowershellscripting

How can I script (e.g. using PowerShell) the action to recycle the app pool of a web site hosted in a Web Role on Azure Cloud Services?

Only one instance of the cloud service is running (used for development). The reason for recycling is to work around a Web Deploy bug.

Best Answer

While I'm not exactly sure of the AppPool name, you should be able to recycle an app pool with appcmd. For example:

appcmd recycle apppool /apppool.name: DefaultAppPool

You can also use PowerShell, by adding WebAdministration and executing Restart-WebAppPool. For example:

Restart-WebAppPool DefaultAppPool

How you execute this would be up to you. Maybe execute it via remote PowerShell. Maybe execute it based on a command you send your web role instance (maybe via queue message or some other technique).