Here’s how to directly connect to the Event Hub that backs an IoT Hub.
Here’s the connection string template, copy this, then copy each highlighted part from each step below.
Endpoint=<Event Hub-compatible endpoint>;SharedAccessKeyName=iothubowner;SharedAccessKey=<iothubowner primary key>
1. Event Hub Compatible Endpoint
In the Azure Portal, go to your IoT Hub, Settings, Operations monitoring:
Set to iothubowner or whatever user you want to use
In the Azure Portal, go to IoT Hub, Settings, Shared access policies, select user and copy Primary Key