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.
- As ServiceBus: Endpoint=sb://{hubname}.servicebus.windows.net/;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname};
- As hostname: HostName={hostName}.azure-devices.net;SharedAccessKeyName={keyname};SharedAccessKey={accesskeyname}
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.