question

DarrenCraine-7197 avatar image
0 Votes"
DarrenCraine-7197 asked DarrenCraine-7197 answered

Event Hub never invokes Javascript triggers

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-functionsazure-event-hubs
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You should tag azure-function as well.

1 Vote 1 ·

@serkantkaraca-msft sorry, missed to do that. Thanks for noticing that.

0 Votes 0 ·

Hi @DarrenCraine-7197,

Thanks for using Microsoft Q&A !!
This question looks more of Azure-functions related, so, adding relevant tag. Please let me know if you any concerns.

Thanks
Saurabh

0 Votes 0 ·
MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered

@DarrenCraine-7197 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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DarrenCraine-7197 avatar image
0 Votes"
DarrenCraine-7197 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.