无法成功运行“ func host start”以测试azure功能

时间:2019-06-26 01:29:09

标签: python-3.x powershell http environment-variables azure-functions

我正在尝试按照此处的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 accont。

一旦我完成了MSDN文档中的提示步骤并运行func host start,powershell将输出以下代码段。出现在我身上的错误是AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.,我已经研究了这个错误,并看到其他人通过Chocolatey卸载并重新安装了azure-functions-core-tools来成功解决了这个问题,我通过按照以下线程进行操作: Azure Python App Function no longer runs locally - module 'azure.functions_worker' has no attribute 'start_async'

问题仍然存在,并且我无法在本地托管azure函数并在浏览器中测试GET / POST请求(http://localhost:7071/api/HttpTrigger)。如果您熟悉如何解决此问题,请帮帮我。我以为这可能是我的Python版本存在的问题,但我通过在Powershell中运行python --version来确认安装了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...

1 个答案:

答案 0 :(得分:0)

我卸载了Python 3.6.0,然后在虚拟环境中安装了Python 3.6.8。然后在同一虚拟环境中卸载并重新安装了azure-functions-core-tools,从而解决了该问题。通过CMD中的Chocolatey进行的卸载和安装。我还暂时禁用了Windows Defender实时扫描。