I came across this link about warming up the IIS application https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/ Can this feature be used for azure cloud services classic? Also I have few Autofac dependencies and I am initializing the db connection object and registering it with the container. Currently I tried out few strategies and since only on the first request this collections will be initialized as a part of health check, I don't see any harm in doing it as a part of health check. Later health check request wont touch the startup part unless App goes into idle state. Is there any harm in applying such a strategy?
2 Answers
If you want warmup your webapp in azure cloud services, you need to create at least 2 webroles.
Your scenario is similar to the problem in this case.
It is recommended that you use azure web app services, currently Azure webapp is relatively mature. There are advantages in pricing, and more features will be provided for web applications. Can also solve your problem well.

- 15,263
- 1
- 14
- 29
-
can i use IIS App Initialization for classic cloud service? thanks! – Batman22 Oct 19 '20 at 02:13
-
I think it should not be possible. – Jason Pan Oct 19 '20 at 02:48
-
[Is it possible to smoothly “hot deploy” an ASP.NET Core app?](https://stackoverflow.com/questions/55503897/is-it-possible-to-smoothly-hot-deploy-an-asp-net-core-app) – Jason Pan Oct 19 '20 at 02:48
-
[hot-deployments with Self Host Web Api Services](https://stackoverflow.com/questions/17757354/hot-deployments-with-self-host-web-api-services) – Jason Pan Oct 19 '20 at 02:49
-
Azure Cloud Services is essentially a server, and you can log in remotely using RDP. I have not found a suitable answer for the hot deployment of IIS so far. If you are interested, as far as I know, the Ctrip development team in China has a solution for you to learn about ʻApollo`. https://github.com/ctripcorp/apollo – Jason Pan Oct 19 '20 at 02:53
Yes, this is possible in classic web roles.
See https://learn.microsoft.com/en-us/archive/blogs/kwill/role-instance-restarts-due-to-os-upgrades, specifically the Common Issues #5 and associated code.
If your website takes several minutes to warmup (either standard IIS/ASP.NET warmup of precompilation and module loading, or warming up a cache or other app specific tasks) then your clients may experience an outage or random timeouts. After a role instance restarts and your OnStart code completes then your role instance will be put back in the load balancer rotation and will begin receiving incoming requests. If your website is still warming up then all of those incoming requests will queue up and time out. If you only have 2 instances of your web role then IN_0, which is still warming up, will be taking 100% of the incoming requests while IN_1 is being restarted for the Guest OS update. This can lead to a complete outage of your service until your website is finished warming up on both instances. It is recommended to keep your instance in OnStart, which will keep it in the Busy state where it won't receive incoming requests from the load balancer, until your warmup is complete. You can use the following code to accomplish this:
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
string ip = null;
foreach (IPAddress ipaddress in ipEntry.AddressList)
{
if (ipaddress.AddressFamily.ToString() == "InterNetwork")
{
ip = ipaddress.ToString();
}
}
string urlToPing = "http://" + ip;
HttpWebRequest req = HttpWebRequest.Create(urlToPing) as HttpWebRequest;
WebResponse resp = req.GetResponse();
return base.OnStart();
}
}

- 10,867
- 1
- 28
- 26