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-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

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.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eventhubs-0.4-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file eventhubs-0.4.tar.gz.

File metadata

  • Download URL: eventhubs-0.4.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for eventhubs-0.4.tar.gz
Algorithm Hash digest
SHA256 ff92bbe75990e735ff083dac4f7874511ba2b1405d3e979318cd34ee48510abe
MD5 b1f2195d2d91a0427b0afc41e2018122
BLAKE2b-256 702e7c8241a0286d4d6d95cc9f7168d84a5c695c4f8bd1b8e48d1b1504af54da

See more details on using hashes here.

File details

Details for the file eventhubs-0.4-py3-none-any.whl.

File metadata

  • Download URL: eventhubs-0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for eventhubs-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7ebd300a5715b5f6623913b8253c4d250c6b4af9eb7e7ec25c96df23f435992a
MD5 2c202ce0c93d1704ac8369e9acfa105f
BLAKE2b-256 f9e520b3884ee429fa33e1c21420136144bbca4eff5ef18d1cafc37c9b86dc4f

See more details on using hashes here.

Supported by

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