Azure/azure-event-hubs-node

Read Azure IoT Hub messages from custom endpoints

formulahendry opened this issue · 2 comments

By following the instruction with below code:

const { EventHubClient } = require('@azure/event-hubs');
 
async function main() {
  const client = await EventHubClient.createFromIotHubConnectionString(process.env["IOTHUB_CONNECTION_STRING"]);
  const hubInfo = await client.getHubRuntimeInformation();
  console.log(hubInfo);
  await client.close();
}
 
main().catch((err) => {
  console.log(err);
});

I could read Azure IoT Hub messages from built-in endpoints. However, when I route message to a custom endpoint (e.g. Azure Storage containers, Event Hubs), I could no longer read the message.

Could I read all messages arrived in IoT Hub no matter where the message will be routed?

Related to microsoft/vscode-azure-iot-toolkit#180

I don't think that is supported. When you provide the iothub connectionstring, we try to connect to the iothub service and they send a redirect error which contains information about the corresponding EventHub endpoint. This is used to then receive messages from the Event Hub.

Reading messages from the Azure Storage container would happen over HTTP protocol. You would be better off using the package from this repo.

If you are redirecting the messages to an EventHub and if you have the connection string of that EventHub, then you can use the EventHub client to establish a connection to that EventHub and receive messages from it.

@pierreca from IotHubs and @sjkwak from EventHubs can provide more information on this.

It looks like there isn't anything we can do here - please feel free to reactivate the issue if that is not the case.