How to run a node.js app in background on Azure

拥有回忆 提交于 2020-01-06 19:24:42

问题


Say I have this simple nodejs app and want to deploy it to Azure as a web app to run in background:

//server.js
function test() {
    // send some request to a url
}
setInterval(test, 10000);

So I'd do this on Heroku by adding a Procfile and a command like worker: node server.js, but what's the equal method for azure?


回答1:


Background tasks in Microsoft Azure App Service are called WebJobs. You can execute any of the following as a WebJob:

  • .cmd, .bat, .exe (using windows cmd)
  • .ps1 (using powershell)
  • .sh (using bash)
  • .php (using php)
  • .py (using python)
  • .js (using node)
  • .jar (using java)

You can read more about WebJobs on Microsoft Azure official documentation center: Run Background tasks with WebJobs

Also, Scott Allen has nice tutorial on node.js and WebJobs: Azure WebJobs With Node.js



来源:https://stackoverflow.com/questions/33850777/how-to-run-a-node-js-app-in-background-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!