如何定义用于运行 azure webjobs 的节点版本?
服务器当前使用 v0.11 执行我的代码,但由于我使用需要节点 >8 的功能而失败
Web 应用程序本身在节点 8 上运行得很好,但 webjobs 的版本似乎独立于 Web 服务器本身。
在 Azure WebApp 上,对于 Node.js 运行时,有一个默认版本,该版本比0.10.40
或其他类似的0.11
如你所说。如果您想更改运行 webjob 的默认 Node 版本,可以通过以下两种方法进行配置。
-
设置值WEBSITE_NODE_DEFAULT_VERSION
与你想要的版本号Application settings
Azure 门户的选项卡。您可以参考我对现有 SO 线程的回答Azure NodeJS 版本.
![enter image description here](https://i.stack.imgur.com/jGJsw.png)
-
要创建一个 zip 文件作为包含 Node JavaScript 和引导文件的 webjob,请参阅官方文档Supported file types for scripts or programs。例如,WebJob zip 文件包括index.js
and run.bat
如下所示,您可以设置PATH
环境添加Azure支持的Node运行时路径(您可以按照我上面的回答列出Azure上NodeJS的所有版本)以使其正常工作。
index.js
console.log(process.version)
run.bat
set PATH=D:/Program Files (x86)/nodejs/8.11.1/;%PATH%
node index.js
![enter image description here](https://i.stack.imgur.com/sE1WA.png)
然后,按照下图步骤,您可以添加并运行您的 webjob zip 文件并通过以下方式查看输出结果Logs
.
![enter image description here](https://i.stack.imgur.com/0i9ce.png)
这是我的结果Logs
当我设置 Node 运行时版本时10.14.1
如下。
![enter image description here](https://i.stack.imgur.com/NkbQX.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)