Updating an AzureFunction from Node 14

To update an Azure Function from Node JS 14 to 18LTS, you need to:

  • Update the host.json with a more recent version of the Microsoft.Azure.Functions.ExtensionBundle (at least 2.6.1). I ended up using [4.0.0, 5.0.0).
    To do so, go to: {YOUR_FUNCTION_APP} > App files > host.json.
  • Update the Runtime version to ~4 (mine was ~3).
    To do so, go to: {YOUR_FUNCTION_APP} > Configuration > Function runtime settings.
  • Update the NodeJS Version to your desired one
    To do so, go to: {YOUR_FUNCTION_APP} > Configuration > General settings

Backstory

Microsoft is deprecating support for Nodejs 14 LTS in Azure Functions, so I needed to update the ones that used it.

I went on and tried to update the Node version from the Function App configuration, but the dropdown allowed me to only select Node.js 14 LTS.

To have more items in the dropdown, I had to go to first update the function runtime to ~4.

Unfortunately, saving it with this runtime and the more recent Node.js crashed the function with the following error:

microsoft.azure.webjobs.script: Error building configuration in an external startup class. Microsoft.Azure.WebJobs.Script: Referenced bundle Microsoft.Azure.Functions.ExtensionBundle of version 1.8.1 does not meet the required minimum version of 2.6.1. Update your extension bundle reference in host.json to reference 2.6.1 or later. For more information see https://aka.ms/func-min-bundle-versions.

To fix it, I needed to:

  • undo the changes to the runtime
  • edit the hosts.json and add a version that is greater than 2.6.1
  • re-do the changes to the runtime

Now the function uses Node.js 18 LTS and all seems to work just fine!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.