1

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);
  }

Credentials from azure

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.

1 Answer 1

0

First of all, are you using a IoTHub or a EventHub? In C# you use the iothub attribute: "IoTHubTrigger".

E.g:

@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 solved many wierd errors for me.

Sign up to request clarification or add additional context in comments.

3 Comments

I totally forgot about this. What I did was using a Built-in endpoint as the connection String.
@maro01507 cool, so you have solved the problem? :)
yep, thanks for trying to help anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.