Azure / azure-functions-python-worker

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

[BUG] Breaking change in 4.11.0 against code using azure-functions 1.13.2 #1225

Closed builtbywill closed 1 year ago

builtbywill commented 1 year ago

Investigative information

Repro steps

Run an http function using azure-functions==1.13.2, on runtime 4.19.0

Expected behavior

I expect it to still work and not throw errors with the older version of azure-functions. I do not expect a patch version of a library to break existing functionality.

Actual behavior

It throws a 500 error with the following exception:

Exception while executing function: Functions.evaluate_answer Result: Failure
Exception: ImportError: cannot import name 'ExternalHttpFunctionApp' 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 383, in _handle__function_load_request
    ExtensionManager.function_load_extension(
  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 65, in function_load_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 14, in <module>
    from .decorators.function_app import (FunctionRegister, TriggerApi, BindingApi,

Known workarounds

Updating to azure-functions==1.13.3 or higher

Contents of the requirements.txt file:

azure-functions==1.13.2

Related information

pdthummar commented 1 year ago

@builtbywill Thanks for reporting the issue. Please use following mitigation to resolve the issue. Team is working on fix and it will be available in future releases.

Potential mitigation would be to try adding the following options:

  1. Remove pinning of the Azure-functions library, or pin 1.14.0+
  2. Enable Dependency Isolation: PYTHON_ISOLATE_WORKER_DEPENDENCIES to 1 in App settings.
  3. Disable Worker Extensions (if you are not using them) - PYTHON_ENABLE_WORKER_EXTENSIONS to 0. If the error persists, please revert the changes.

Thanks

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.