Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change python version of azure function

Tags:

python

azure

When I publish my azure cloud functions I get the message:

Local python version '3.9.7' is different from the version expected for your deployed Function App. This may result in 'ModuleNotFound' errors in Azure Functions. Please create a Python Function App for version 3.9 or change the virtual environment on your local machine to match 'Python|3.8'.

How can I change the version to 3.9?

like image 691
Quinten C Avatar asked Jun 09 '26 23:06

Quinten C


2 Answers

  • You can view and set the linuxFxVersion from the Azure CLI.
  • With the az functionapp config set command, you can change the linuxFxVersion setting in the function app.
az functionapp config set --name <FUNCTION_APP> \
 --resource-group <RESOURCE_GROUP> \
 --linux-fx-version "PYTHON|3.9"

Please refer Changing Python version for more information.

like image 194
Harshitha Veeramalla Avatar answered Jun 11 '26 12:06

Harshitha Veeramalla


For those of you facing the following error when attempting the solution provided by Harshitha:

    '3.9' is not recognized as an internal or external command,
operable program or batch file.

This is because '|' needs to be escaped within the string "PYTHON|3.9" to work in PowerShell. This will work:

'Python"|"3.9'

like image 34
Arunothia Avatar answered Jun 11 '26 12:06

Arunothia