Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
EventHub Receiver
const EventHubClient = require('azure-event-hubs').Client;
const Promise = require('bluebird');
const connectionString = '__OBFUSCATED__';
const eventHubPath = 'foo';
const client = EventHubClient.fromConnectionString(connectionString, eventHubPath);
var printError = function(err) {
var receiveAfterTime =;
.then(function() {
console.log('Client connected');
return client.getPartitionIds();
.then(function(partitionIds) {
return, function(partitionId) {
return client.createReceiver('$Default', partitionId, {
'startAfterTime': receiveAfterTime
}).then(function(receiver) {
receiver.on('errorReceived', printError);
receiver.on('message', function(event) {
console.log(`partitionId: ${partitionId}, partitionKey: ${event.partitionKey}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment