Meraj Kashi
Meraj Kashi

Reputation: 343

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

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

Upvotes: 5

Views: 7290

Answers (3)

Joe Gurria Celimendiz
Joe Gurria Celimendiz

Reputation: 480

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)
  

Upvotes: 0

Martin Naughton
Martin Naughton

Reputation: 1556

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.

Upvotes: 9

silent
silent

Reputation: 16138

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

Upvotes: 1

Related Questions