This is a small console program which reads messages from an Azure Event Hub and prints them on the console. There are some options to filter message content or write to file.
You can download the tool from the Releases or download the source code and run dotnet build.
-
Run the
EventHubReader.exewith the connection string
.\EventHubReader.exe "Endpoint=sb://<myendpoint>.servicebus.windows.net/;SharedAccessKeyName=<keyName>;SharedAccessKey=<key>;EntityPath=<eventHubName>"This will print the messages to the console.
You can press space to pause printing to console. Caution: messages will still be consumed in the background but the output to the console holds. If you press space again the next message available will be printed. You can pause the output to examine a message without scrolling back up in the console.
Use --help to see configuration options:
> .\EventHubReader.exe --help
USAGE:
EventHubReader.exe [connectionString] [OPTIONS]
ARGUMENTS:
[connectionString] Azure Event Hub connection string as presented in the Azure portal
OPTIONS:
-h, --help Prints help information
-g, --consumer-group Consumer group of Event Hub to read from. Default value '$Default'
-c, --contains Only messages which contain this string will be printed. Can be added multiple times
-n, --not-contains Messages containing this string will not be printed. Can be added multiple times
-f, --file Writes output to file- Use specific consumer group
> .\EventHubReader.exe "some connection string" --consumer-group "my-fancy-consumer-group"- Print all messages containing
appleandhousebut notbanana
> .\EventHubReader.exe "some connection string" --contains "apple" --contains "house" --not-contains "banana"- Write all messages additionally to file
message.txt
> .\EventHubReader.exe "some connection string" --file "message.txt"This repo is heavily inspired by Peter-B and his IoT hub client. Thank you.
