I have a durable app function running on versions 3.x written in pyhton 3.7 that worked fine from the last 1 year. After a new release due to a minor change in software I had to redeploy the function app via
func azure functionapp publish
When I try to run it locally using the Debug tool in VS Code I don't get any error and everything works fine, but now when I run it in cloud (in az portal for instance) i get this error:
Result: Failure Exception: ImportError: cannot import name 'FunctionRegister' from 'azure.functions' (/azure-functions-host/workers/python/3.7/LINUX/X64/azure/functions/init.py). Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 318, in _handle__function_load_request func_request.metadata.entry_point) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 85, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/home/site/wwwroot/ClientStarter/init.py", line 5, in import azure.durable_functions as df File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/durable_functions/init.py", line 14, in from .decorators import DFApp File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/durable_functions/decorators/init.py", line 4, in from .durable_app import DFApp File "/home/site/wwwroot/.python_packages/lib/site-packages/azure/durable_functions/decorators/durable_app.py", line 10, in from azure.functions import FunctionRegister, TriggerApi, BindingApi, AuthLevel
I understood that there are some problems with module due to pyhton version and app version but I cannot go with 4.x, is there a way to still use 3.x and avoid the error?
Any help is appreciated
3条答案
按热度按时间pobjuy321#
最简单的短期解决方案是将requirement.txt中的版本修改为1.1.6版
fcg9iug32#
我今天遇到了这个确切的问题-将Python升级到3. 9,并将Azure函数升级到运行时版本~4,解决了这个问题。
btxsgosb3#
对于运行时堆栈为
Python
的Azure函数应用程序,限制为Python 3.9
。在执行visual studio代码中的持久函数之前,我得到了如下相同类型的警告:
它声明它支持最高
Python 3.10
版本来执行Visual Studio代码中的durable orchestrator
函数,但不是最新的版本。(Python 3.11)注意:使用持久性函数时,必须检查版本兼容性(Python)。否则,将引发“导入错误"。
在满足所有先决条件后,我尝试通过安装依赖项在我的环境中创建和执行示例编排器、活动以及客户端函数,结果成功运行。
编排器-〉
init.py
:要求.txt:
持久性HttpStarter函数-〉
init.py
:输出:
已触发[本地主机:7071/API/编排程序/函数名称]:
检查运行时状态[本地主机:7071/API/编排程序/状态查询获取Uri]:
部署成功:
x1c4d 1x指令集
已发布到门户中的函数应用程序:
指令集
更新日期:
参考:MSDoc