Am trying to set a trigger from an Azure function to read all data that comes from my IoT hub. For that, I followed this tutorial .
After setting the connection string inside my local settings, when I try to launch my function, I get the following error:
The 'functionName' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.functionName'. Microsoft.WindowsAzure.Storage: Value cannot be null. (Parameter 'connectionString').
I have tried to add the endpoint as a servicebus, or directly as a hostname, but in both I have the same error.
To add further clarify, I will show my implementation:
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "java",
"app_trigger_hub_name": "{hubname}",
"app_trigger_connection": "Endpoint=sb://{hubname}.servicebus.windows.net/;SharedAccessKeyName={accessKey};SharedAccessKey={sharedKey}",
}
}
Azure Function trigger
@FunctionName("functionName")
public void eventHubProcessor(
@EventHubTrigger(name = "functionName", eventHubName = "%app_trigger_hub_name%",
connection = "app_trigger_connection") String message,
final ExecutionContext context) {
context.getLogger().info(message);
}
EDIT
After some trial & error I managed to get the connection using the servicebus, but still not working. Now when I start the function, I got the following error:
The listener for function 'Functions.function' was unable to start. Microsoft.Azure.EventHubs.Processor: Encountered error while fetching the list of EventHub PartitionIds. System.Private.CoreLib: nodename nor servname provided, or not known.
First of all, are you using a IoTHub or a EventHub? In C# you use the iothub attribute: "IoTHubTrigger".
Eg:
@FunctionName("ehprocessor")
public void eventHubProcessor(
@IoTHubTrigger(name = "msg",
eventHubName = "myeventhubname",
connection = "myconnvarname") String message,
final ExecutionContext context )
{
context.getLogger().info(message);
}
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;
And for the connectionString you use the "Event Hub compatible endpoint", that you can find under "Built-in endpoints" in the azure portal.
I saw your edited part now, have you tried to empty your eventhub container locally? "azure-webjobs-eventhub"? that have solve many wierd errors for me.
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.