Long-running intervals in Azure with Node.js

I'm running a Node.js app in an Azure website and I'm trying to get a timer to go off every 30 seconds indefinitely. I've tried using both setInterval and node-cron but both of these stop working after about half an hour. There are no errors in the logs, and the site stays up, but the timer stops firing. I can start or recreate the timer again but it just stops working after another half an hour.

I am on the free trial period, am I running into some sort of account restriction here? Or is there some other way I should be doing this or some way to work out what is making the timer stop?

When hosting Node.js on a website (or in fact using the node.js powershell support for Cloud Services) your node process is hosted by IISNode.

IISNode will manage the lifecycle of the node process. I'm guessing it's intentionally shutting you down after 30 minutes.

You need to run node yourself in Azure if you want a process that's going to stay up. There are two options:

  1. Use the Virtual Machines (currently in preview), and manually copy node.exe, and your javascript onto a virtual machine, and start your app manually (or as a scheduled task or something). You can use either Windows or Linux.
  2. Use Cloud Services, and create a Worker Role which starts node as a startup task. This gives you the ability to scale as well.