Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Appcmd startup task, setting preloadEnabled for ALL sites

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?

like image 791
mattytommo Avatar asked Apr 18 '13 14:04

mattytommo


2 Answers

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
like image 80
mattytommo Avatar answered Sep 19 '22 14:09

mattytommo


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
like image 20
Abhinav Galodha Avatar answered Sep 19 '22 14:09

Abhinav Galodha