Open matttrakker opened 3 years ago
I am able to reproduce it with
[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
Short intro: HTTP Trigger which is calling the function, then take a message and put that via output binding to 4 other eventhubs
Repro steps
Provide the steps required to reproduce the problem:
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 }; }```