Azure Functions-Eventhub Trigger not Triggering

Palanisamy, Sathish 1 Reputation point
2021-05-14T21:16:10.137+00:00

I have an Azure Function with Event hub Trigger, when i publish the non JSON message i see a Serialization Error. But when i publish a proper JSOn message i dont see the Event triggering the Function's. I dont see any error in the Insight Live streams/Logs. Below is my Functions.java and function.json.

Not sure what i am missing

public class Function {
/**
*
*/
@FunctionName("ehprocessor")
public void eventHubProcessor(
@EventHubTrigger(name = "pnrmessage",
eventHubName = "casperpnr",
connection = "EventHubConnectionString"
)List<String> message,
final ExecutionContext context )
{
context.getLogger().info("received the message *****");
context.getLogger().info(message.toString());
}

}

// JSON:

{
"scriptFile" : "../Azure-Functions-EventHubTrigger-1.0-SNAPSHOT.jar",
"entryPoint" : "com.aa.casper.pnrprocessorfunction.Function.eventHubProcessor",
"bindings" : [ {
"type" : "eventHubTrigger",
"direction" : "in",
"name" : "pnrmessage",
"connection" : "EventHubConnectionString",
"eventHubName" : "casperpnr",
"cardinality" : "MANY"
} ]
}

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-05-17T13:01:05.833+00:00

    Hi @Palanisamy, Sathish

    I have tested the code at my end and it is working as expected. I will suggest you to stream the logs by navigating to you function app --> Monitor --> Logs.
    If you have enabled application insights then the exception/logs should be logged in it. There might be some delay with the data of application insights.

    Java code:

    public class Function {  
      
        @FunctionName("ehprocessor")  
            public void eventHubProcessor(  
                @EventHubTrigger(name = "message", eventHubName = "maktest",connection = "EventHubConnectionString") List<String> messages,   
                final ExecutionContext context )         
        {  
              context.getLogger().info("Java EventHub trigger processed a request.");  
      
              context.getLogger().info(messages.toString());  
        }  
      
    }  
    

    If you are testing locally then make sure you have AzureWebJobsStorage and EventHubConnectionString define in your local.settings.json with the connection string value. If you are running in the azure function the same setting should be defined in your application setting of function app else it will give 500 error or runtime exception.

    {  
      "IsEncrypted": false,  
      "Values": {  
        "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=storageaccountname;AccountKey=yourkey;EndpointSuffix=core.windows.net",  
        "EventHubConnectionString":"Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yourkey",  
        "FUNCTIONS_WORKER_RUNTIME": "java"  
      }  
    }  
    

    As you have defined it as List<String> so the input should event should be a list of an array. If any other input is provided JSON, string, etc, then you will receive a Serialization exception.

    ["this is test1","this is test2"]

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.