azure webapp webjob node version

五迷三道 提交于 2019-12-02 20:10:11

问题


How can I define the node version that is used to run azure webjobs?

The server currently executes my code with v0.11 and fails since I use features that require node >8

The web app itself runs on node 8 just fine, but the version for webjobs seems to be independent of the webserver itself.


回答1:


On Azure WebApp, for Node.js runtime, there is a default version which be older that 0.10.40 or others like 0.11 as you said. If you want to change the default Node version for running your webjob, there are two ways below to configure it.

  1. To set the value of WEBSITE_NODE_DEFAULT_VERSION with the version number you want in Application settings tab of Azure portal. You can refer to my answer for the existing SO thread Azure NodeJS version.

  2. To create a zip file as webjob which wrapped your Node JavaScript and a bootstrap file, please refer to the offical document Supported file types for scripts or programs. For example, a WebJob zip file includes index.js and run.bat as below, you can set the PATH environment to add the Node runtime path supported by Azure (you can list all version of NodeJS on Azure by following my answer above) to make it works.

    index.js

    console.log(process.version)
    

    run.bat

    set PATH=D:/Program Files (x86)/nodejs/8.11.1/;%PATH%
    node index.js
    

    Then, following the below figure steps, you can add & run your webjob zip file and see the output result via Logs.

Here is my result in Logs when I set my Node runtime version 10.14.1 as below.



来源:https://stackoverflow.com/questions/54771467/azure-webapp-webjob-node-version

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