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?

Asked By: Quinten Cabo

||

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'

Answered By: Arunothia
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.