I am getting this error when I am trying to connect to IoT Hub using Azure functions:
The listener for function 'IoTHubDataFunction' was unable to start. Microsoft.Azure.EventHubs.Processor: Encountered error while fetching the list of EventHub PartitionIds. 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.
This is my function app code. It simply has an IoT Hub trigger and a consumer group and it logs the incoming message.
[FunctionName("IoTHubDataFunction")]
public static void Run([IoTHubTrigger("messages/events", Connection = "IoTHubTriggerConnection", ConsumerGroup = "funcgroup")]EventData message, ILogger log)
{
log.LogInformation($"C# IoT Hub trigger function processed a message: {Encoding.UTF8.GetString(message.Body.Array)}");
}
And this is my local.settings.json file
{
"IsEncrypted": false,
"Values": {
"IoTHubTriggerConnection": "My IoT Hub connection string",
"AzureWebJobsStorage": "Storage connection string",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
I am getting the IoT Hub connection string from Azure portal: