# Upgrading a Functions App and Code-base to the v4 Runtime References. - [Migrate apps from Azure Functions version 3.x to version 4.x](https://learn.microsoft.com/en-us/azure/azure-functions/migrate-version-3-version-4?tabs=net6-in-proc%2Cazure-cli%2Cwindows&pivots=programming-language-javascript) - [Azure Functions runtime versions overview](https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=v4&pivots=programming-language-javascript#migrating-from-3x-to-4x) - [Work with Azure Functions Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cmacos%2Ccsharp%2Cportal%2Cbash#install-the-azure-functions-core-tools) - [Durable Functions versions overview](https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-versions) - [Extension bundles](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-register#extension-bundles) - [Fix output data serialization format in Node.js functions #2007](https://github.com/Azure/Azure-Functions/issues/2007) > _Version 3.x of the extension bundle doesn't include the Table Storage bindings, if you require the Table Storage binding, you should continue using the 2.x version._ ## Actions - Run the **```Functions 4.x Pre-Upgrade Validator```** in _Azure ➜ Functions App ➜ Diagnose and Solve Problems_ - ➜ Remove **AzureWebJobsDashboard** app setting _this is a legacy setting that may have been added when creating older function apps_ - ➜ Remove **APPINSIGHTS_INSTRUMENTATIONKEY** app setting _this gets added by default when you enable Application Insights using the Azure Portal_ - ➜ Upgrade local **Azure Functions Core Tools** to **v4** ``` # I'm using homebrew, otherwise you should pick your package manager of choice # but the same one you originally installed any previous version of the core tools with!!! brew tap azure/functions brew install azure-functions-core-tools@4 # if upgrading on a machine that has 2.x or 3.x installed: brew link --overwrite azure-functions-core-tools@4 ``` - Set NVM default Node to **`v16`** ``` nvm alias default 16.17.0 ``` - Set **`hubName`** in **`host.json`** to **``** or _`durablefunctionshub` (this is the default if not supplied)_ ``` { "extensions": { "durableTask": { "hubName": "", } } } ``` - Upgrade the **extension bundle** to **v2** Set **`extensionBundle`** to **2.\*, 3.0.0** in **`host.json`** _This is a minimum requirement for the functions v4 runtime and is also a requirement to use **durable entities** with durable functions v2.0, so the extension upgrade is a win-win_ ``` { "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[2.*, 3.0.0)" } } ``` - Change the durable client function binding type from **```orchestrationClient```** to **```durableClient```** in **all** `function.json` files - Change **FUNCTIONS_EXTENSION_VERSION** to **~4** in `local.settings.json` - Update _Dev/Debug_ webpack build process to also copy the non-functional **`package.json`** file from the **`src`** folder to the **`dist`** folder ## Upgrade the Azure Functions App to use the v4 runtime - Set the functions app **runtime version** to **v4** See: [az functionapp config appsettings set](https://learn.microsoft.com/en-us/cli/azure/functionapp/config/appsettings?view=azure-cli-latest#az-functionapp-config-appsettings-set) ``` az functionapp config appsettings set --settings "FUNCTIONS_EXTENSION_VERSION=~4" --resource-group --name ``` - Set the functions app **node version** to **16** ``` az functionapp config appsettings set --settings "WEBSITE_NODE_DEFAULT_VERSION=~16" --resource-group --name ``` - Set the functions app **.NET version** to **v6.0** -- _only for OS type=Windows*_ See: [az functionapp config set](https://learn.microsoft.com/en-us/cli/azure/functionapp/config?view=azure-cli-latest#az-functionapp-config-set) _The default for the v3 runtime is ```"netFrameworkVersion": "v4.0"```_ ``` az functionapp config show --resource-group --name az functionapp config set --net-framework-version v6.0 --resource-group --name ``` - **Restart** the functions app See: [az functionapp restart](https://learn.microsoft.com/en-us/cli/azure/functionapp?view=azure-cli-latest#az-functionapp-restart) ``` az functionapp restart --resource-group --name ``` --- > If you visit the functions app in the Azure Portal now you will see the following error in the **Overview** blade. > This is because the extension bundle of the currently deployed project code-base does not meet minimum version requirements for the **v4** runtime. > > _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. > > > **Redeploy your updated codebase.** > > > **```** If the error persists *****************************************```** > > see this article: https://stackoverflow.com/questions/75991406/how-do-you-solve-azfd0005-azure-function-app-error > > **```******************************************************************```** > --- - **Remove** the **node_modules** folder and **re-install package dependencies** _Ensure you've upgraded your Node version to 16, 14 etc_ ``` rm node_modules or del node_modules npm install ``` - **Build and deploy** the updated project code-base