I am setting up an example where I have an Azure Function with a webhook that has an Azure Event Hub as a sink. There are two different consumer groups for this event hub, one of which is used by another Azure Function. The code doesn't do anything too fancy (excerpts are below), but I am observing an odd pattern. For every two messages published, only one appears to trigger the function once.
Publishing web hook:
module.exports = function (context, req) {
var statusCode = 400;
var responseBody = "Invalid request object";
if (typeof req.body != 'undefined' && typeof req.body == 'object') {
var eventInformation = req.body;
context.log("Received event: " + eventInformation);
context.bindings.outEvent = eventInformation;
statusCode = 200;
responseBody = "Event received.";
}
context.res = {
status: statusCode,
body: responseBody
};
context.done();
};
Receiving function:
module.exports = function (context, offerMadeEvent) {
var connection = new Connection(dbConfig); // Tedious connection
connection.on('connect', function(err) {
context.log('Connection established.');
// Somewhere in the database callbacks:
context.done();
});
};