Azure Event Hub: How can I see what the Event Hub does?

271 views Asked by At

I have inherited an Azure Event Hub as a ressource for management and usage. Unfortunately there is no documentation. I can only see a Event Hub Namespace Ressource and there is one Event Hub Entity, which is active. If I click on it, there is only a $Default consumer group and I can't figure out what the Event Hub does. Is it possible to see what the Event hub does and how can I retrieve information through the Event Hub?

Thanks!

Edit: This is the current code I'm using. I can authenticate but I don't receive any messages or I can't retrieve what Event Hub is providing. How can I receive the data?

from confluent_kafka import Consumer, KafkaException, KafkaError

bootstrap_servers = SERVER
topic = TEST_HUB
group_id = ID

# Kafka Config

consumer_config = {
    'bootstrap.servers': bootstrap_servers,
    'group.id': group_id,
    'auto.offset.reset': 'earliest',
    'enable.auto.commit': False,
    'security.protocol': 'SASL_SSL',
    'sasl.mechanism': 'PLAIN',
    'sasl.username': '$ConnectionString',
    'sasl.password': MY_EVENT_HUB_ENDPOINT
}

# Consumer
consumer = Consumer(consumer_config)


# Subscribe to the azure event hub
consumer.subscribe([topic])

# Consume messages from Kafka 
try:
    while True:
        message = consumer.poll(5.0)

        if message is None:
            continue

        if message.error():
            if message.error().code() == KafkaError._PARTITION_EOF:
                # End of partition event
                continue
            else:
                # Handle error
                print(f"Error: {message.error().str()}")
                break

        # Process the Kafka message
        key = message.key()
        value = message.value()
        print(value)

        # Commit the message offset
        consumer.commit(message)

except KeyboardInterrupt:
    pass

finally:
    # Close
    consumer.close()
1

There are 1 answers

2
Neha Tawar On

Event Hubs exposes the events for any consumer wishing to read them. for more details refer : Azure Event Hub And refer1 , refer2

Hope it helps.