https://github.com/zmoog/eventhubs
Simple Python-based CLI tool to receive and publish messages on Azure Event Hub.
https://github.com/zmoog/eventhubs
Last synced: 4 months ago
JSON representation
Simple Python-based CLI tool to receive and publish messages on Azure Event Hub.
- Host: GitHub
- URL: https://github.com/zmoog/eventhubs
- Owner: zmoog
- License: apache-2.0
- Created: 2023-02-22T19:35:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-10-30T13:53:48.000Z (8 months ago)
- Last Synced: 2025-10-30T15:39:23.569Z (8 months ago)
- Language: Python
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eventhubs
[](https://pypi.org/project/eventhubs/)
[](https://github.com/zmoog/eventhubs/releases)
[](https://github.com/zmoog/eventhubs/actions?query=workflow%3ATest)
[](https://github.com/zmoog/eventhubs/blob/master/LICENSE)
CLI tool to send and receive event data from Azure Event Hubs
## Installation
Install this tool using `pip`:
pip install eventhubs
## Usage
### Receiving
For receiving data to an event hub, run:
eh eventdata receive
### Sending
For sending a single event to an event hub, run:
eh eventdata send-event --text '{"message": "Hello Spank"}'
You can also send multiple events in a batch by using the `send-batch` command with `--text` multiple times:
eh eventdata send-batch --text '{"message": "Hello Spank"}' --text '{"message": "Hello Spank (yes, again)"}'
For sending the lines in a text files as event, run:
eh eventdata send-batch --lines-from-text-file multiline.txt
For sending the lines from `stdin` as event, run:
cat multiline.txt | eh eventdata send-batch
### Configuration
You can set up the connection string and event hub name using the command line options:
eh eventdata receive --connection-string "Endpoint=.." --name "application-insights"
or the environment variables (or a mix of both):
export EVENTHUB_CONNECTION_STRING="Endpoint=sb://...="
export EVENTHUB_NAME="application-insights"
eh eventdata receive
eh eventdata receive --name "another-name"
Defaults to printing the message payload only, so it is easier to combine output with other tools, like `jq`:
$ eh eventdata receive | jq '.records[].tenantId'
"1de2b364-21e1-4866-bb46-7804f17c417d"
"1de2b364-21e1-4866-bb46-7804f17c417d"
"1de2b364-21e1-4866-bb46-7804f17c417d"
But you can still turn on verbose and get more information about what's going on:
$ eh --verbose eventdata receive
Receiving events from mbranca
Received event from partition 0: {"records": [{....
For help, run:
eventhubs --help
You can also use:
python -m eventhubs --help
## Development
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd eventhubs
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest