简体   繁体   English

如何在Azure Webjobs中运行Node.js?

[英]How to run node.js in azure webjobs?

我有几个节点js脚本文件。我必须在Azure Web作业中运行这些JS文件。任何人都可以告诉我如何在Azure Web作业中添加Node.js文件以及如何运行这些Web作业的详细步骤。 。

It's relatively easy if you know some undocumented details :) 如果您知道一些未记录的细节,这相对容易:)

The key concept is ensuring correct application structure (for Azure). 关键概念是确保正确的应用程序结构(适用于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. 您的主要应用程序脚本应命名为run.js ,换句话说,您的应用程序应能够通过执行node run.js命令正确启动。

What is more don't count on your package.json dependencies. 而且,不要指望package.json依赖项。 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. 根据我自己的经验,我可以说package.json依赖项有时可以工作,有时不能,所以手动上载node_modules/更为安全。

You may add multiple app files by Zipping them and uploading inside Azure App > WebJob panel. 您可以通过压缩文件并在Azure应用> WebJob面板中上传来添加多个应用文件。

If your app has no bugs it should be running a few seconds after the upload. 如果您的应用程序没有错误,则应在上传后几秒钟运行。

For more info checkout this blog post . 有关更多信息,请查看此博客文章

Like the previous answers state, it's really as easy as adding .js files to your web job and following the instructions. 像之前的答案状态一样,这实际上就像将.js文件添加到您的Web作业并按照说明进行操作一样容易。 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. 唯一与该过程有关的事情是,如果您在Node脚本中需要任何第三方模块,则必须压缩.js文件和node_modules文件夹,然后部署整个内容-node_modules文件夹以及全部。

If you have a file with a .js extension it'll be run as a node program 如果您使用扩展名为.js的文件,则它将作为节点程序运行

Full documentation on Azure Web Jobs here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ 有关Azure Web作业的完整文档,请访问此处: https : //azure.microsoft.com/zh-cn/documentation/articles/web-sites-create-web-jobs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM