python-3.x - 无法成功运行“func host start”来测试 azure 函数
问题描述
我正在尝试按照此处的 MSDN 说明对 python azure 函数进行一些本地测试: https ://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
我已经安装了所有必要的依赖项,包括 Python 3.6、Azure Functions Core Tools、Azure CLI 并且我有一个有效的 Azure 订阅。我还通过az login
powershell 管理员模式登录了我的 Azure 帐户。
一旦我完成了 MSDN 文档中的提示步骤并运行func host start
powershell 输出以下代码段。对我来说突出的错误是 AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
我已经研究了这个错误并看到其他人通过巧克力卸载和重新安装 azure-functions-core-tools 成功解决了它,我按照这里的线程完成了:Azure Python App Function no本地运行时间更长 - 模块“azure.functions_worker”没有属性“start_async”
问题仍然存在,我无法在本地托管 azure 函数并在浏览器中测试 GET/POST 请求(http://localhost:7071/api/HttpTrigger)如果您熟悉如何解决此问题,请帮助我问题。我认为这可能是我的 Python 版本的问题,但我确认已通过python --version
在 powershell 中运行安装了 Python 3.6.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Http Functions:
HttpTrigger: [GET,POST] http://localhost:7071/api/HttpTrigger
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:31 AM] main()
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Language Worker Process exited.
[6/26/2019 1:24:31 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:31 AM] Starting language worker process:python "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py" --host 127.0.0.1 --port 64242 --workerId afead7f3-0f5e-4209-91f5-7904d3319d56 --requestId 9a2be9af-32d1-4199-9aaa-0d4aef01eef2 --grpcMaxMessageLength 134217728
[6/26/2019 1:24:31 AM] python process with Id=2360 started
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:31 AM] main()
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Language Worker Process exited.
[6/26/2019 1:24:31 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:31 AM] Starting language worker process:python "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py" --host 127.0.0.1 --port 64242 --workerId 899213f3-400d-4355-a0cb-a42e425ef551 --requestId 2e8c49ea-6b15-444a-9e97-a07eefe09808 --grpcMaxMessageLength 134217728
[6/26/2019 1:24:31 AM] python process with Id=10060 started
[6/26/2019 1:24:32 AM] Traceback (most recent call last):
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:32 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:32 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:32 AM] Traceback (most recent call last):
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:32 AM] main()
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:32 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:32 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:32 AM] Language Worker Process exited.
[6/26/2019 1:24:32 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:32 AM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[6/26/2019 1:24:32 AM] Shuttingdown Rpc Channels Manager
[6/26/2019 1:24:32 AM] Stopping host...
[6/26/2019 1:24:32 AM] Stopping JobHost
[6/26/2019 1:24:32 AM] Job host stopped
[6/26/2019 1:24:32 AM] Host shutdown completed.
Application is shutting down...
解决方案
我卸载了 Python 3.6.0,然后在虚拟环境中安装了 python 3.6.8。然后在解决问题的同一虚拟环境中卸载并重新安装 azure-functions-core-tools。通过 CMD 中的巧克力完成卸载和安装。我还暂时禁用了 Windows Defender 实时扫描。
推荐阅读
- linux - 使用python停止进程
- java - 为什么从静态初始化程序启动线程并等待其完成会导致死锁?
- r - 删除标签之间的字符串 ()
- azure - Azure Pipeline (YAML) 将一个空解决方案部署到我的 FunctionApp
- javascript - C# DateTime 到 Javascript 日期
- string.format - java String.format - 如何在两个字符之间放置一个空格
- sublimetext3 - 使用“open_file”命令打开特定行号的文件
- html - 显示 HTML
- css - 如何仅使用 CSS 访问字体为“courier new”的文本?
- vue.js - 赛普拉斯在访问()之后永远不会到达第 2 步 - 卡在 nuxt-loading 中