python - Azure函数应用程序: Microsoft. Azure.WebJobs.EventHubs : Value cannot be null.(参数 'receiverConnectionString')

标签 python azure function

我遵循以下结构,但上传功能应用程序后,我遇到错误:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-iot-trigger?tabs=python

错误:

函数(转换/EventHubTrigger1)错误:Microsoft.Azure.WebJobs.Host:索引方法“Functions.EventHubTrigger1”出错。 Microsoft.Azure.WebJobs.EventHubs:值不能为空。 (参数“receiverConnectionString”)。 session ID:cb179cdab03c4e8c80f1f82d9da9d143

时间戳:2020-03-11T15:55:55.575Z

enter image description here

<小时/>
Function.json :
{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "event",
      "direction": "in",
      "eventHubName": "iothub-ehub-neas-hub-xxx-xxxx",
      "connection": "Endpoint=sb://xxxxxxxxxxxx.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxxxxx=;EntityPath=iothub-ehub-neas-hub-xxxxxx-856659355a",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}

最佳答案

您需要将端点信息放入 local.settings.json 中并从 function.json 中引用它。 XXXX只是为了显示更多。连接字符串是您在事件中心门户中获得的内容。我在节点中设置时遇到了同样的问题。

Local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "AzureEventHubConnectionString": "Endpoint=XXXX",
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=XXXX"
  }
}

然后在你的 function.json 中

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "IoTHubMessages",
      "direction": "in",
      "eventHubName": "<event hub name you have>",
      "connection": "AzureEventHubConnectionString",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}

这将消除 receiveConnectionString 错误。

关于python - Azure函数应用程序: Microsoft. Azure.WebJobs.EventHubs : Value cannot be null.(参数 'receiverConnectionString'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60640205/

相关文章:

python - PyQt4:如何重新排序子部件?

azure - 使用适用于 Xamarin Android 的 Azure 移动服务从 Google Api 获取用户信息

javascript - 正确使用 const 来定义函数

javascript - Mini-Max Sum - 使用 JavaScript 返回两个(或更多)间隔数字

减法时的 Python timedelta 行为

python - 气象站项目中的KeyError

python - 对对象方法使用 Python 模拟的 autospec 的正确方法是什么?

angular - 服务工作线程不适用于 Azure 静态 Web 应用上的自定义域

windows - 为什么我无法为入站 HTTP 和 HTTP 添加防火墙豁免?

C 字符串返回函数返回垃圾