Rashad Ibrahimov
Rashad Ibrahimov

Reputation: 3309

How to upgrade nodejs version on Azure

Currently I have Azure function and Node.js version 6.5.0 defined by default there. The goal is to upgrade it. I've checked the list of available Node.js versions on Azure, and the latest one is 8.9.4. I've read some documentation about it, where 2 ways to do it are mentioned.

1) package.json

Put the following configuration to package.json file

"engines": {
    "node": "8.9.4"
}

So I did it, but no success.

2) Application Settings

Go to Application Settings, and update the value for WEBSITE_NODE_DEFAULT_VERSION to 8.9.4

Here I have 3 issues with this method:


One more issue with Azure Functions: When I deploy a function with changes, Azure Portal web UI still shows me not updated function (old one), while new version of that function is running there. Weird...

Please let me know if any of you faced these issues, and maybe someone knows the reason or even solution. Thank you.

Upvotes: 4

Views: 7418

Answers (4)

Shailesh Jha
Shailesh Jha

Reputation: 1202

You can set the WEBSITE_NODE_DEFAULT_VERSION By checking the nodejs version from D://program files(x86)/nodejs. It will list up with all available versions. Choose one and update WEBSITE_NODE_DEFAULT_VERSION

This worked for me. I have changed 8.11 to 8.11.1

Upvotes: 2

Jerry Liu
Jerry Liu

Reputation: 17790

logging process.version in function shows me 6.11.0.

As @David has said, Azure Functions runtime v1(~1) locks your node version at v6.11.

When changing WEBSITE_NODE_DEFAULT_VERSION to 8.9.4, you also need to change runtime version FUNCTIONS_EXTENSION_VERSION to beta in your application settings.

(Note that runtime switch may cause breaking changes, you can create a new function app instead if error occurs.)

And the first method using package.json doesn't work in my test.

some ES6 features like async arrow functions throws an error

After successful update of node version, async arrow functions also works fine in my test.

each time I run serverless deploy command it recreates service and resets WEBSITE_NODE_DEFAULT_VERSION value to default one

serverless deploy is a command to deploy the whole service. So it's normal to see the recreating(back to default v6.5) happen as there's no parameter for node version in your yml file.

To avoid this, use serverless deploy -f <functionname> to deploy specific function instead of the whole app.

When I deploy a function with changes, Azure Portal web ui still shows me not updated function (old one), while new version of that function is running there

Same thing happened on my side. I found script can be shown correctly in App Service Editor. But in portal and kudu, update fail to display. I also checked log files in kudu, it says Script for function 'functionname' changed. Reloading..

Have opened an issue on github about the last issue we met.

Upvotes: 6

David Makogon
David Makogon

Reputation: 71031

Just to formalize, from my comment: Functions runtime v1 is locked down to a specific Node.js version (6.11.2 currently), per this reference document.

To use a configurable Node.js runtime, you'll, need to upgrade your Functions runtime to v2.x:

Function overview page

Function app settings, to change runtime

Upvotes: 3

Maharramoff
Maharramoff

Reputation: 1021

Go to your App directory you will see iisnode.yml. Make sure that node.js version correctly specified there also. There should be something like this:

nodeProcessCommandLine: some_dir\nodejs\8.9.4\node.exe

enter image description here

Upvotes: -2

Related Questions