Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
332 stars 100 forks source link

Fix extensions code for py39 consumption #1304

Closed gavin-aguiar closed 10 months ago

gavin-aguiar commented 11 months ago

Python 3.9 on consumption is throwing the following error with library 1.16

Result: 
Failure Exception: ImportError: cannot import name 'SettingsApi' from 'azure.functions.decorators.function_app' (/azure-functions-host/workers/python/3.9/LINUX/X64/azure/functions/decorators/function_app.py)
Stack:
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 479, in _handle__invocation_request call_result = await self._loop.run_in_executor( 
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 752, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, 
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 213, in _raw_invocation_wrapper cls._invocation_extension(ctx, APP_EXT_PRE_INVOCATION, args) 
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 19, in call return func(*args, **kwargs) 
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 112, in _invocation_extension sdk = cls._try_get_sdk_with_extension_enabled() 
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 225, in _try_get_sdk_with_extension_enabled sdk = get_sdk_from_sys_path() 
File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/common.py", line 121, in get_sdk_from_sys_path module = importlib.import_module('azure.functions') 
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) 
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked 
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked 
File "<frozen importlib._bootstrap_external>", line 850, in exec_module 
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed 
File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/functions/__init__.py", line 15, in <module> from .decorators.function_app import (FunctionRegister, TriggerApi