Sean Dong
Sean Dong

Reputation: 615

Azure startup task Appcmd to config my site

I have a azure site running, and I want to solve the notorious application pool restart warm up issue. It seems that MS has release for Application Initialization IIS.

So I have to do the following 1. Install Application Initialization 2. Make some configuration changes mentioned in here http://learn.iis.net/page.aspx/1089/iis-80-application-initialization/

a) In Application pool section of %WINDIR%\system32\inetsrv\config\applicationhost.config file

b) In site section of %WINDIR%\system32\inetsrv\config\applicationhost.config file ... ....

My question is, how to write the Appcmd script to solve 2. b) to add preloadEnabled="true" to the right place, because i need to do 1) find the root site, given that I dont know the sitename, nor the site id. 2) add the preloadEnabled="true" property to the root site I found in step 2).

Upvotes: 1

Views: 2903

Answers (5)

Mathew Thompson
Mathew Thompson

Reputation: 56429

Coupled with David's answer to reset the idle timeout, you can also prevent the app pools from recycling at all by using the following as a startup task:

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.time:00:00:00

You also need to set two other things: startMode and preloadEnabled.

For startMode, you can add this to the startup task you created for the code above:

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.startMode:AlwaysRunning

For preloadEnabled, you can do what Alex said and do this in your startup task:

appcmd set app "websitename/vdirname" /preloadEnabled:true

Upvotes: 1

Alex Laverty
Alex Laverty

Reputation: 485

I know this is an old question but to hopefully answer this part :

how to write the Appcmd script to solve 2. b) to add preloadEnabled="true" to the right place, because i need to do

Use the appcmd :

appcmd set app "websitename/vdirname" /preloadEnabled:true

Regards Alex

Upvotes: 0

ionwarp
ionwarp

Reputation: 215

If you are looking to configure the site/application pool using an AppCmd startup task, check out my recent post about this:

http://mvolo.com/configure-iis-websites-windows-azure-startup-tasks-appcmd/

This covers how to find the site/application pool to edit, and also how to run the task AFTER the site/apppool configuration is created and not before.

We are actually enabling application warmup via serviceAutoStartProviders using this approach, I will blog about the configuration tool we use / issues we solved in a later post.

If you need help with that now, send me an email.

Upvotes: 0

Ming Xu - MSFT
Ming Xu - MSFT

Reputation: 2116

There's a sample on http://blogs.msdn.com/b/tom/archive/2011/02/18/installing-and-using-an-httpmodule-in-windows-azure.aspx. Essentially, you need to set executionContext to elevated, so your web role's entry point (but not ASP.NET application) will run under administrator previlige. Inside the entry point, you can use IIS administration API to configure the warm up module.

Upvotes: 0

David Makogon
David Makogon

Reputation: 71033

As far as avoiding restart, add this command to your startup script:

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00

Not sure about your preload question.

Upvotes: 0

Related Questions