Skip to main content

CLI tool to send and receive event data from Azure Event Hubs

Project description

eventhubs

PyPI Changelog Tests 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 --text '{"message": "Hello Spank"}'

You can also send multiple events in a batch by using --text more than once:

eh eventdata send --text '{"message": "Hello Spank"}' --text '{"message": "Hello Spank (yes, again)"}'

For sending the lines in a text files as event, run:

eh eventdata send --lines-from-text-file multiline.txt

For sending the lines from stdin as event, run:

cat multiline.txt | eh eventdata send  

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eventhubs-0.2.2.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

eventhubs-0.2.2-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page