问题
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