简体   繁体   中英

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

I follow below structures, but after uploading function app on, I face error:

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

Error:

Function (transformation/EventHubTrigger1) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.EventHubTrigger1'. Microsoft.Azure.WebJobs.EventHubs: Value cannot be null. (Parameter 'receiverConnectionString'). Session Id: cb179cdab03c4e8c80f1f82d9da9d143

Timestamp: 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"
    }
  ]
}

you need to put the endpoint information in your local.settings.json and reference it from the function.json. The XXXX is just to show the is more. The connection strings are what you get in the event hub portal. i had the same issue setting up in node.

Local.settings.json

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

Then in your function.json

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

That will get rid of the receiverConnectionString error.

In the connection field you do not put in the connection string itself. Instead you put in the name (ie Key) of an application setting . In this one you put in the connection string.

Following up from Martin Naughton's post, also, you need to ensure you have the connection string name in the function's Run method:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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