What version of Node.js can you use in Azure Functions

What version of Node.js can you use in Azure Functions

When building Azure Functions using Node.js, the Functions' runtime version dictates the version of Node.js you can use. And you better know it upfront.

Following are the Azure Function runtimes and the corresponding Node.js versions:

Azure Functions runtime Node.js version
1.x v6
2.x v8 and v10
3.x (preview) v8 and v10

Serverless for the win

Azure Functions are the easiest way to run a piece of code on Azure. Within minutes, you can create HTTP APIs or processes scheduled by timers or events. Using the integration capabilities, you can communicate with tables or queues and even send emails. And if your code needs to handle some extraordinary load, you can scale your Functions too.

Choose your language

You can build Azure Functions in several languages like C# or JavaScript. But you can't just use any version of .NET or Node.js. Here is why.

Mind the runtime

Azure Functions work on a specific runtime version. If you created your Function App in the past, you could be running on runtime 1.x. If you create a Function App today, you will be running on 2.x. There is also a beta of 3.x. So why is this important?

Each runtime supports specific versions of the platform that you use to build your functions (eg. .NET or Node.js). If you, for example, build your Azure Functions with Node.js, you cannot choose any version of Node.js. Instead, you need to stick to the version(s) supported by your Azure Functions runtime. This can lead to issues in cases when you're working with a Function App that has been created a while ago and will try to use language features that are not supported in your version. The error message that you will get will be confusing, to say the least, and it will take you some time to figure out, that you're simply running on an older version of your platform of choice that doesn't support that particular feature. But couldn't you just upgrade your Function's runtime version?

UI for selecting Azure Function runtime disabled when Function App has functions in it

Unfortunately not. When your Function App has any functions in it, the UI to choose the runtime version will be disabled. The reasoning behind it is, that changing the runtime could break your code. So instead, you should either create a new Function App with a newer runtime and migrate your code there or remove your code, upgrade the runtime version and move it back in. You could also try to hack the Function App's config files but it's not recommended.

So before you write any Functions, check first which version of runtime your Function App is on and which version of your language you can use. It will help you avoid surprises down the line.

Comments

comments powered by Disqus