繁体   English   中英

Azure 函数 - 事件中心“连接尝试失败”错误

[英]Azure Functions - Event Hub "A connection attempt failed" error

我使用 Azure Function 中的时间触发器编写了 python 代码,该代码从 Z8A5DA52ED126447D359E 获取数据并将其发送到 Event Hub210。 当我执行 function 时,我收到以下错误:

System.Private.CoreLib: Exception while executing function: Functions.TimerTrigger. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. System.Private.CoreLib: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

我的 function.json 如下所示:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "mytimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */1 * * * *"
    },
    {
      "type": "eventHub",
      "name": "output",
      "eventHubName": "eventhub-af-project",
      "connection": "myconnection",
      "direction": "out"
    }
  ]
}

该连接在我的 local.settings.json 以及 Azure 的配置选项卡中定义。 我使用了具有管理、发送和侦听权限的连接字符串-主键。

有什么我错过的吗?

Main function 中,将返回类型从None更改为str

def main ( mytimer: func.TimerRequest ) -> str :

此外,您的connection属性应该具有包含连接字符串的应用程序设置的名称,如下所示:

  "type": "eventHub",
  "name": "$return",
  "eventHubName": "sqlserverstreaming",
  "connection": "MyConnStringAppSetting",
  "direction": "out"

然后创建一个名为MyConnStringAppSetting的应用程序设置,并将完整的连接字符串放入其中。

请参阅此处以获取完整示例SO 参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM