How to change python version of azure function
Question:
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?
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.
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'
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?
- 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.
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'