How to run node.js in azure webjobs?

2019-04-15 06:31发布

I am having several node js script files.I have to run these js files in azure web jobs.can any one tell me the detail step for how to add the node.js files in azure web jobs and also how to run these web jobs.

3条回答
ら.Afraid
2楼-- · 2019-04-15 06:54

Like the previous answers state, it's really as easy as adding .js files to your web job and following the instructions. The only thing that's particular about the process is that if you require any 3rd party modules in your Node script, then you have to zip up the .js files and the node_modules folder and deploy the whole thing - node_modules folder and all.

查看更多
The star\"
3楼-- · 2019-04-15 06:55

If you have a file with a .js extension it'll be run as a node program

Full documentation on Azure Web Jobs here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/

查看更多
手持菜刀,她持情操
4楼-- · 2019-04-15 06:58

It's relatively easy if you know some undocumented details :)

The key concept is ensuring correct application structure (for Azure). Your main application script should be named run.js, so in other words, your app should be able to start properly by executing node run.js command.

What is more don't count on your package.json dependencies. From my own experience, I can tell that package.json dependencies sometimes work and sometimes not, so it is much safer to upload the node_modules/ manually.

You may add multiple app files by Zipping them and uploading inside Azure App > WebJob panel.

If your app has no bugs it should be running a few seconds after the upload.

For more info checkout this blog post.

查看更多
登录 后发表回答