16

Okay, so I'm basically in the process of implementing azure warmups using the new IIS 8.0 Application Initialization module.

I've got a startup task (cmd file) that basically already cancels out the idle timeout in IIS and the recycling time. I'm trying to add application initialization to that.

I realise that I need to set two things; startMode and preloadEnabled.

My application has numerous sites in IIS (around 10), all randomly named by Azure with their own randomly named Application Pools.

startMode is easy, as that can be set as an application pool default by doing:

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

That applies it to all the application pools.

However, it's not so easy with preloadEnabled.

To set preloadEnabled, you can use this for a named site:

%windir%\system32\inetsrv\appcmd set config -section:sites [name='MySite'].applicationDefaults.preloadEnabled

But I need it to apply to ALL sites that I don't know the name of (they're random), kind of a default (how I have set startMode).

Any ideas?

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • have you tried that one: `appcmd.exe set config -section:system.applicationHost/sites /applicationDefaults.preloadEnabled:"True" /commit:apphost` – astaykov Apr 18 '13 at 19:08
  • @astaykov preloadEnabled isn't an option on site defaults, it can only be set per site (I tried it, it said such setting didn't exist – Mathew Thompson Apr 19 '13 at 08:34
  • In your architecture, do you dynamically add sites, or sites are fixed when you build the Cloud Service package and when you deploy, no changes are made (i.e. no new sites are added or removed) ? – astaykov Apr 19 '13 at 12:04

4 Answers4

14

After a day of searching for it, I've finally got it. It basically uses a loop in appcmd by using the pipe to chain commands together (kinda like a for loop). Here it is:

%systemroot%\system32\inetsrv\AppCmd.exe list app /xml | %windir%\system32\inetsrv\appcmd set site /in -applicationDefaults.preloadEnabled:True
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • When I use this I get: Publish-AzureServiceProject : BadRequest : Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation. – Shawn Miller Oct 03 '14 at 22:04
2

For IIS 8.5, to Set, the preload at the application level (not at Site Level) using appcmd, following command should be utilized.

appcmd set app "Default Web Site/ApplicationName" /preloadenabled:true
Abhinav Galodha
  • 9,293
  • 2
  • 31
  • 41
0

For those still on IIS 7.5:

laktak
  • 57,064
  • 17
  • 134
  • 164
0

In windows Server 2012 R2 and IIS 8.5 in to CMD Adminitrator.

cd C:\Windows\System32\inetsrv && appcmd list app /xml | appcmd set site /in -applicationDefaults.preloadEnabled:True /commit:apphost

Roberto Ramos
  • 553
  • 6
  • 16