How to Update the Node.Js Version in Azure Function?


microsoft-azure How to Update the Node.Js Version in Azure Function? cloud Microsoft Azure nodejs

microsoft-azure

What is Azure Function?

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. Azure Functions supports scripting in Node.js, Python, C#, Java, PHP and PowerShell. It is mainly used for event-driven processing and process automation. You can use Azure Functions to build web API endpoints or for data processing such as image resizing, order processing, or file maintenance.

Azure Function is the Serverless technology similar to AWS Lambda, Google Cloud Function, or CloudFlare Worker. Azure Function can be implemented using various programming languages such as NodeJs, .NET, and can run on Windows or Linux OS. This post shows you how to update the Node.Js version for Azure Function.

I have a azure function in Node.Js, how to change the node.js version?

You can specify the Node.js version that your Azure Function runs on by changing the WEBSITE_NODE_DEFAULT_VERSION setting in the application settings of your function app. Here’s a step-by-step guide:

  • Log in to the Azure portal.
  • In the left-hand menu, click on “Function Apps”.
  • In the function apps list, click on the name of your function app.
  • In the function app’s left-hand menu, click on “Configuration”.
  • In the Application settings tab, look for a setting with the name WEBSITE_NODE_DEFAULT_VERSION. If it’s there, click the edit button (looks like a pencil) to the right of the setting.
  • Change the value of the setting to the Node.js version you want to use (e.g., 12.13.0).
  • If the WEBSITE_NODE_DEFAULT_VERSION setting does not exist, click the “+ New application setting” button at the top of the application settings list. Enter WEBSITE_NODE_DEFAULT_VERSION as the name and your desired Node.js version as the value.
  • Click “OK” to close the setting edit dialog, then click “Save” at the top of the page to save your changes.

Azure will restart your function app with the new Node.js version.

JS How to Update the Node.Js Version in Azure Function? cloud Microsoft Azure nodejs

NodeJs / Javascript

Please note, Azure Functions supports specific versions of Node.js. As of my knowledge cutoff in September 2021, the supported versions are 8.11.1, 8.11.2, 10.14.1, 10.19.0, 12.13.0, 12.18.0, 14.15.0, 14.16.0. Before specifying a version, you should check Azure’s documentation or ask the Azure support team to confirm that the version you want to use is supported.

Is it possible to change this setting in config.json or appsettings.json?

In Azure Functions, the WEBSITE_NODE_DEFAULT_VERSION is not typically set via a config.json or appsettings.json file. These files are not part of the Azure Functions environment and changes to them would not affect the runtime environment of your Azure Function.

However, for local development, you can use the local.settings.json file to specify settings for your function app. This file is used by the Azure Functions Core Tools for local development and is not deployed to Azure. In this file, you can specify the Values property to include WEBSITE_NODE_DEFAULT_VERSION, like so:

1
2
3
4
5
6
7
8
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "WEBSITE_NODE_DEFAULT_VERSION": "12.13.0"
  }
}
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "WEBSITE_NODE_DEFAULT_VERSION": "12.13.0"
  }
}

For deployment, app settings are typically set in the Azure portal, or can be set using the Azure CLI or Azure PowerShell. If you’re deploying from GitHub, you can also specify these settings in your azuredeploy.json file.

Remember to replace “12.13.0” with the Node.js version you want to use.

Azure CLI az command to update the Node.JS version of Azure Function

Here are a few commands that might be useful to update the Node.JS version and the function extention runtime using the Azure CLI command aka az functionapp

1
2
3
az functionapp config set --name <AZURE_FUNCTION_NAME> --resource-group <RESOURCE_GROUP> --linux-fx-version "node|17"
az functionapp config appsettings set --name <AZURE_FUNCTION_NAME>--resource-group <RESOURCE_GROUP> --settings FUNCTIONS_EXTENSION_VERSION=~4
az functionapp config appsettings set --name <AZURE_FUNCTION_NAME>--resource-group <RESOURCE_GROUP> --settings WEBSITE_NODE_DEFAULT_VERSION=17.1.0
az functionapp config set --name <AZURE_FUNCTION_NAME> --resource-group <RESOURCE_GROUP> --linux-fx-version "node|17"
az functionapp config appsettings set --name <AZURE_FUNCTION_NAME>--resource-group <RESOURCE_GROUP> --settings FUNCTIONS_EXTENSION_VERSION=~4
az functionapp config appsettings set --name <AZURE_FUNCTION_NAME>--resource-group <RESOURCE_GROUP> --settings WEBSITE_NODE_DEFAULT_VERSION=17.1.0

Azure Functions

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
934 words
Last Post: Best Advice for IT or Software Development Career
Next Post: Blockchain Consensus Algorithm: What is Delegated Proof of Stake (DPoS) ?

The Permanent URL is: How to Update the Node.Js Version in Azure Function?

Leave a Reply