Azure Event Hubs is a "highly scalable data streaming platform capable of ingesting millions of events per second". Basically it allows you to integrate different systems by sending asynchronous messages resulting in low coupling between systems.

For .NET just grab the nuget package and you're up and running. For Node there is a NPM package called azure-event-hubs. It is maintained by Microsoft and is currently in version 0.0.7: https://www.npmjs.com/package/azure-event-hubs

Writing to and reading from event hubs is pretty straight forward. Examples can be found on Github: https://github.com/Azure/azure-event-hubs-node/blob/master/samples/javascript-eventhub-sample/simple_eventhubs_client.js

Sending messages containing properties becomes a bit more complicated. In .NET you would simply add your properties to the EventData.Properties collection and then send the message. In azure-event-hubs for Node, the option to add properties is not exposed. Fortunately the EventHubSender returned by EventHubClient.createSender exposes the underlying AMQP (Advanced Message Queuing Protocol)  link used. We can use this to send a raw AMQP message to event hubs.

var azure = require('azure-event-hubs');
var eventHubsClient = azure.Client.fromConnectionString('connection string', 'event hub name');

var event = "data to send"; // could be an object or whatever. No need to serialize it beforehand.

eventHubsClient.open()
    .then(function() {
        return eventHubsClient.createSender();
    })
    .then(function(tx) {
        tx.on('errorReceived', function (err) {
            console.error(JSON.stringify(err));
        });

    var options = {
        applicationProperties: {
            'my property':'some value'
        }
    };

    var msg = {
        body: event
    };

    return tx._senderLink.send(msg, options);
})
.catch(function(err) {
    console.error(err.message);
});

The properties placed in options -> applicationProperties will be added to the Properties collection in .NET. If you wish to add system properties such as EnqueuedTimeUtc or PartitionKey these should be added to options -> messageAnnotations. The system properties are named as below:

C# AMQP
SequenceNumber x-opt-sequence-number
Offset x-opt-offset
EnqueuedTimeUtc x-opt-enqueued-time
PartitionKey x-opt-partition-key

Comment