Azure-functions-host: Linux nodejs function with multiple eventhub output bindings not sending data

Created on 17 Feb 2021  路  5Comments  路  Source: Azure/azure-functions-host

Short intro:
HTTP Trigger which is calling the function, then take a message and put that via output binding to 4 other eventhubs

  • Timestamp: 2021-02-17T09:53:41.423
  • Function App version: 3
  • Function App name: [company data, try to deliver everything else]
  • Function name(s) (as appropriate): Functions.HttpTrigger1
  • Host InstanceId ID: f00d3e73-aec3-4f1d-9931-fbd2e8c0e309
  • Executing 'Functions.HttpTrigger1' ID: 2b28d94b-82d6-4ba0-8069-4d4d5d065c02
  • Region: westeu
    [cannot see the function started id in the logs]

Repro steps

Provide the steps required to reproduce the problem:

  • create four eventhubs
  • create a function app in an appserviceplan
  • create a http trigger function with four output bindings to the corresponding eventhubs
  • call that function

Expected behavior

Would have expected the message to be delivered to all four eventhubs

Actual behavior

Nothing happens, just trigger no error no issue.

Known workarounds

none

BUT if you comment out three of the four output bindings then the left one ist working.
You can do this for every output, so the connection strings are not the problem.
AND the same can be reproduced with python...

Related information

Stack NodeJS
NodeJs 12 LTS
Authorization anonymous

Appsettings the Connectiong strings to the hubs


Source

```javascript

module.exports = async function (context, req) {

const name = (req.query.name || (req.body && req.body.name));
const responseMessage = name
    ? "Hello, " + name + ". This HTTP triggered function executed successfully."
    : "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";

let tempBufferDEV = [{'fruit':'Apple'}, {'fruit':name}];
let tempBufferTEST = [{'fruit':'Apple'}, {'fruit':name}];
let tempBufferSTAGE = [{'fruit':'Apple'}, {'fruit':name}];
let tempBufferPROD = [{'fruit':'Apple'}, {'fruit':name}];

// test
context.bindings.outputEventHubIoTDataMessagesTest = tempBufferTEST;

// dev
context.bindings.outputEventHubIoTDataMessagesDev = tempBufferDEV;

// stage
context.bindings.outputEventHubIoTDataMessagesStage = tempBufferSTAGE;

// prod
context.bindings.outputEventHubIoTDataMessagesProd = tempBufferPROD;

context.res = {
    // status: 200, /* Defaults to 200 */
    body: responseMessage
};

}```

Triage (Functions)

Most helpful comment

@alrod @AnatoliB Could you please evaluate this item for an upcoming sprint? Thanks

All 5 comments

I am able to reproduce it with

  • Windows 10
  • .NET / v3 Functions
        [FunctionName("HttpIngress")]
        public static async Task<IActionResult> HttpIngress(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            [EventHub("iotdata", Connection = "dev_iotdata_EVENTHUB")] IAsyncCollector<string> outputEventsDev,
            [EventHub("iotdata", Connection = "test_iotdata_EVENTHUB")] IAsyncCollector<string> outputEventsTest,
            [EventHub("iotdata", Connection = "stage_iotdata_EVENTHUB")] IAsyncCollector<string> outputEventsStage,
            [EventHub("iotdata", Connection = "prod_iotdata_EVENTHUB")] IAsyncCollector<string> outputEventsProd,
            ILogger log)
        {
            string message = $"Message at {DateTime.UtcNow}";
            await outputEventsDev.AddAsync(message);
            await outputEventsTest.AddAsync(message);
            await outputEventsStage.AddAsync(message);
            await outputEventsProd.AddAsync(message);

            string responseMessage = "OK";

            return new OkObjectResult(responseMessage);
        }

I observe that the 4 messages end up in the first EventHub.

@mathewc @alrod Could you please take a look at this?

The issue is possibly here: https://github.com/Azure/azure-functions-eventhubs-extension/blob/51be2e6eccd2b01ab32ebdf80160a9449b718418/src/Microsoft.Azure.WebJobs.Extensions.EventHubs/Config/EventHubOptions.cs#L210-L221

Notice in @KaiWalter's sample the Event Hubs names are the same, but connection strings are different. However, it appears the extension uses a cache that's keyed only on the Event Hub name and not the connection string.

For me it is the same, we use the same hubname in all four environments, so the name is equal, the connection string not

That line here https://github.com/Azure/azure-functions-eventhubs-extension/blob/51be2e6eccd2b01ab32ebdf80160a9449b718418/src/Microsoft.Azure.WebJobs.Extensions.EventHubs/Config/EventHubOptions.cs#L97 will also always result in an issue when you use the same hubname in multiple bindings(I guess)
I would create a pr, but I'm just not deep enough in that code base but @anthonychu your guesses are really exactly looking like the issue - thanks for checking!

@alrod @AnatoliB Could you please evaluate this item for an upcoming sprint? Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

justinyoo picture justinyoo  路  3Comments

mathewc picture mathewc  路  4Comments

paulbatum picture paulbatum  路  4Comments

christopheranderson picture christopheranderson  路  4Comments

silencev picture silencev  路  3Comments