Azure Appcmd startup task, setting preloadEnabled for ALL sites
Asked Answered
U

4

17

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?

Upshaw answered 18/4, 2013 at 14:40 Comment(3)
have you tried that one: appcmd.exe set config -section:system.applicationHost/sites /applicationDefaults.preloadEnabled:"True" /commit:apphostHomogamy
@Homogamy preloadEnabled isn't an option on site defaults, it can only be set per site (I tried it, it said such setting didn't existUpshaw
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) ?Homogamy
U
15

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
Upshaw answered 19/4, 2013 at 13:12 Comment(1)
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.Taunyataupe
I
4

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
Interplay answered 17/2, 2016 at 20:28 Comment(0)
E
0

For those still on IIS 7.5:

Edithe answered 21/10, 2013 at 7:42 Comment(0)
P
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

Pyszka answered 18/2, 2019 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.