6

I have a WebAPI application running on Azure WebSites. It is running in Basic mode and I have the option to make it "Always On". There seems to be conflicting information online about what this means exactly. I know the effect, but the "how" matters a lot here. In particular, does something automatically hit an endpoint in my application periodically? If so, can I control the endpoint it hits?

As I mentioned, it is a Web API application and the default route does non-trivial work and results in a notable amount of outbound traffic and it will also result in items being placed onto a work queue that will eventually be processed. I want the application always on (no cold start times) but I don't want some service making requests of application.

Micah Zoltu
  • 6,764
  • 5
  • 44
  • 72
  • some information was in this post: http://stackoverflow.com/questions/21840983/will-always-on-setting-prevent-both-idletimeout-and-periodicrestart – Erik Oppedijk Oct 27 '14 at 12:55
  • I see this tidbit, "If a site happens to restart for any other reason Always On will make sure to start your site and send a request to the site root /." which suggests that they do hit site root on startup. I am still curious whether they will hit site root to keep it alive. – Micah Zoltu Oct 27 '14 at 16:09
  • 2
    Doing non-trivial work on the "default" URL of any service seems like it would lead to this kind of problem; most automated systems make the assumption that the root of a site is just a landing page. I would **strongly** suggest changing that design so an HTTP GET on your application root costs you as little as possible. – Paul Turner Oct 27 '14 at 17:33
  • 1
    @Micah, yes it will hit the root of your website. – Amit Apple Oct 27 '14 at 17:55
  • @Tragedian I agree, and am working towards a model where site root does nothing. The services I write tend to do only one thing, so they only have one endpoint and putting that endpoint at default seemed reasonable. However, if not Azure punishing me for it then someone else will eventually. :( – Micah Zoltu Oct 27 '14 at 22:20

1 Answers1

9

As soon as your Azure Website is marked as AlwaysOn, your site root will be hit within a few seconds. We also make sure your site is up and running on all the workers (if you have configured auto scale option or such). After that, if the worker process crashes, alwaysOn makes sure that it comes back up. You cannot control the endpoint that it hits.

  • Not the answer I wanted, but the correct one I believe. – Micah Zoltu Oct 27 '14 at 22:15
  • 1
    I have not tried this yet but you could set applicationInitialization in - http://www.iis.net/configreference/system.webserver/applicationinitialization - your web.config to specify which page you want to hit. - I will try this out and confirm. – Ranjith Ramachandra Oct 27 '14 at 22:41
  • So did applicationinitialization work to control the endpoint hit or will it simply add another request to the specified endpoint after the request to site root? – Søren Boisen Sep 29 '16 at 09:32
  • You can specify the url to hit with applicationinitialization. – Ranjith Ramachandra Oct 20 '16 at 05:09
  • @RanjithRamachandra Can you provide any information on how applicationInitialization corresponds to the AlwaysOn feature? Am I correct in understanding that you are saying that it can dictate the address being hit by the AlwaysOn feature? – Jaxidian Mar 14 '17 at 13:52
  • 1
    With applicationInitialization feature, you can specify relative paths (to your site) that will called when your site starts up. AlwaysOn always hits the root of the site but if you configure application initialization, that will hit whatever path you specify in the config. – Ranjith Ramachandra Mar 15 '17 at 03:16
  • @RanjithRamachandra I can't confirm that applicationInitialization anything has to do with the AlwaysOn feature. The url in applicationInitialization only gets called after deploying or when the application is restarting. Always on requests remain on /. – martinoss Jul 03 '17 at 15:15
  • I came up writing a rewrite rule that rewrites the root page to the one I specified in applicationInitialization. – martinoss Jul 04 '17 at 16:04