繁体   English   中英

Azure 886982359588 应用程序:Microsoft.Azure.WebJobs.EventHubs:值不能为 null。(参数“receiverConnectionString”)

[英]Azure Function app : Microsoft.Azure.WebJobs.EventHubs: Value cannot be null. (Parameter 'receiverConnectionString')

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

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

错误:

Function(转换/EventHubTrigger1)错误:Microsoft.Azure.WebJobs.Host:索引方法“Functions.EventHubTrigger1”时出错。 Microsoft.Azure.WebJobs.EventHubs:值不能为 null。(参数“receiverConnectionString”)。 Session 编号:cb179cdab03c4e8c80f1f82d9da9d143

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

在此处输入图像描述


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 只是为了显示更多。 连接字符串是您在事件中心门户中获得的内容。 我在 node.js 中设置了同样的问题。

本地设置.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"
    }
  ]
}

这将摆脱receiverConnectionString 错误。

connection字段中,您不要输入连接字符串本身。 相反,您输入应用程序设置的名称(即密钥)。 在这个中,您输入了连接字符串。

根据 Martin Naughton 的帖子,您还需要确保在函数的 Run 方法中有连接字符串名称:

   public async Task Run([EventHubTrigger("samples-workitems", Connection = "AzureEventHubConnectionString")] EventData[] events, ILogger log)
  

暂无
暂无

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

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