Event Hub never invokes Javascript triggers

Darren Craine 1 Reputation point
2021-08-27T11:06:26.977+00:00

Hi

I am setting up a simple POC of Event Hub where I am pushing data into a Hub and then having triggers react to it. Unfortunately I have not been able to get a trigger to invoke.

This is my function.json:

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "eventHubMessages",
      "direction": "in",
      "eventHubName": "playfab-events",
      "storageConnection": "AzureWebJobsStorage",
      "connection": "darrenanalytics_RootManageSharedAccessKey_EVENTHUB",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ],
  "scriptFile": "../dist/EventsTrigger/index.js"
}

And this is my local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage":"DefaultEndpointsProtocol=https;AccountName=darrenazureplayfabfuncti;AccountKey=XXXXXXXXXXX;EndpointSuffix=core.windows.net",
    "darrenanalytics_RootManageSharedAccessKey_EVENTHUB": "Endpoint=sb://darren-analytics.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXX"
  }
}

I can verify data is getting into the Event Hub, and I can set up Event Grid triggers against it as well. Any help would be appreciated.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,210 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
555 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 68,391 Reputation points
    2021-09-01T12:17:43.44+00:00

    @Darren Craine The local.settings.json and function.json looks good but I see that you have define the scriptFile. By default, a JavaScript function is executed from index.js, a file that shares the same parent directory as its corresponding function.json Please confirm if this is the entry point.

    The other reason of your function app not getting triggered would be if your event hub or function app is under the restricted network or vnet. Please verify if this is not the case. I will suggest you to debug your application locally and verify if you observed the same behaviour and if yes then what is the error/warning that is displayed in terminal while running your function app.

    If it is deployed in azure then I will suggest you to review your application insights logs to verify if there is any expection/error while executing the function or the runtime has some issue.

    I have created the test application at my end without defining the script file and my eventhub/function was not under the vnet and couldn't observe any issue with the same function.json and local.settings.json that you have shared.

    0 comments No comments

  2. Darren Craine 1 Reputation point
    2021-09-03T23:27:28.933+00:00

    Everything I posted was auto generated by the VS Code Azure plugin.

    The app is not under a restricted network or vnet and the default entry point is fine. There are no logs because it never gets called.

    I gave up on this approach because it was a waste of time debugging it and I defined everything in Pulumi and it worked fine. Thanks for the reply though.

    0 comments No comments