Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipharding/fdefbc185526b60caf1a06bf0182e486 to your computer and use it in GitHub Desktop.
Save phillipharding/fdefbc185526b60caf1a06bf0182e486 to your computer and use it in GitHub Desktop.
Upgrading a Functions App and Code-base to the v4 Runtime

Upgrading a Functions App and Code-base to the v4 Runtime

References.

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 <preferred hub name> or durablefunctionshub (this is the default if not supplied)
{
	"extensions": {
		"durableTask": {
			"hubName": "<preferred hub name>",
		}
	}
}
  • 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

az functionapp config appsettings set --settings "FUNCTIONS_EXTENSION_VERSION=~4" --resource-group <resource group> --name <functions app name>
  • Set the functions app node version to 16
az functionapp config appsettings set --settings "WEBSITE_NODE_DEFAULT_VERSION=~16" --resource-group <resource group> --name <functions app name>
  • Set the functions app .NET version to v6.0 -- only for OS type=Windows*

See: az functionapp config set

The default for the v3 runtime is "netFrameworkVersion": "v4.0"

az functionapp config show --resource-group <resource group> --name <functions app name>
az functionapp config set --net-framework-version v6.0 --resource-group <resource group> --name <functions app name>
  • Restart the functions app

See: az functionapp restart

az functionapp restart --resource-group <resource group> --name <functions app 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment