Azure Function stuck using Python 3.9 despite configuring for Python 3.11 in runtime.txt and settings
I’ve been trying to run an Azure Function using Python 3.11, but no matter what I do, the logs indicate that the function is running Python 3.9. I’ve gone through multiple deployment attempts and configurations but can’t seem to resolve this.
- I’m deploying my function as a ZIP package. I’ve confirmed that the runtime.txt is included and correctly set to python-3.11.
- I used unzip -l to confirm the structure of the ZIP file, and the runtime.txt is at the root level with the correct Python version specified.
- have set FUNCTIONS_WORKER_RUNTIME to python in the Azure Function App’s Configuration settings.
- I’ve checked the App Service Plan and confirmed it’s a Linux-based Consumption Plan (Y1), which supports Python 3.11.
- I’ve redeployed the function multiple times, each time ensuring the configuration and deployment package is correct.
- And Yes, I've checked my requirements.txt as well and made sure it was included in the my zip folder.
I don't know what else I could be doing wrong. Python is 3.11 on my local, on the portal, its everywhere, but where I need it. When I run a test curl via the portal I always a sudden 500 error and then this "Exception type: Microsoft.Azure.WebJobs.Host.FunctionInvocationException Exception message: Exception while executing function: Functions.vector_similarity_search
Exception: ModuleNotFoundError: No module named 'openai'. Cannot find module. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound.
Current sys.path: ['/tmp/functions\standby\wwwroot', '/home/site/wwwroot/.python_packages/lib/site-packages', '/azure-functions-host/workers/python/3.9/LINUX/X64', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 479, in _handle__function_load_request func = loader.load_function( File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/site/wwwroot/vector_similarity_search/init.py", line 5, in