KafkaConsumer connecting to Azure EventHub returning Partition count as Zero (0)

Kumar Sugandh 90 Reputation points
2026-07-27T18:02:34.8733333+00:00

Hi Team,

We are using the Kafka-clients Java library to connect to Azure Event Hubs. We have observed that the partition count is returned as 0, despite the Event Hub having 4 partitions. We are using the primary connection string from the SaaS Policy to establish the connection.

Please let me know if you need any additional details.

Any pointers for debugging this issue would be greatly appreciated.

Azure Event Hubs
0 comments No comments

2 answers

Sort by: Most helpful
  1. Ganesh Chelluri 190 Reputation points Microsoft External Staff Moderator
    2026-08-04T06:19:03.8633333+00:00

    Hi @Kumar Sugandh ,

    Thank you for the update.

    Since you've confirmed that:

    • The consumer is able to subscribe successfully.
    • The Event Hub name and SAS policy are correct.
    • The SAS policy has both Listen and Send permissions.

    it appears that authentication and connectivity are working as expected.

    To investigate why the partition count is being returned as 0, could you please provide the following information?

    1. Which Kafka client version are you using?
    2. Which Java version are you running?
    3. Could you share your Kafka consumer configuration (with sensitive information redacted), especially the following properties? bootstrap.servers security.protocol sasl.mechanism sasl.jaas.config request.timeout.ms metadata.max.age.ms
    4. Please enable DEBUG logging for the Kafka client and share the MetadataRequest and MetadataResponse immediately after the consumer subscribes.
    5. Could you confirm whether calling partitionsFor("<event-hub-name>") also returns 0 partitions, or is the issue only observed after subscribe()?
    6. Are you able to reproduce the same behavior using another Kafka client (for example, the Kafka console consumer or a simple sample application)?

    This information will help determine whether the metadata returned by Azure Event Hubs is incorrect or whether the Kafka client is not processing the metadata as expected.

    Looking forward to your update.

    Was this answer helpful?


  2. Jose Benjamin Solis Nolasco 10,731 Reputation points Volunteer Moderator
    2026-07-27T18:47:09.2733333+00:00

    Welcome to Microsoft Q&A,

    Hello @Kumar Sugandh I hope you are doing well.

    If the Event Hub has 4 partitions but Kafka reports 0, I recommend checking:

    • Verify that the Kafka client is connecting to the correct Event Hubs namespace and Event Hub.
    • Confirm that the Event Hub name is being used as the Kafka topic name.
    • Verify the SAS connection string and that the policy has the required permissions.
    • Check the Kafka client configuration, particularly bootstrap.servers, security.protocol, and sasl.mechanism.
    • Enable Kafka DEBUG logging and review the metadata request/response to confirm what the client receives from Event Hubs.

    Since you are using the primary SAS connection string, also verify that the EntityPath points to the intended Event Hub.

    If the issue persists, please share the Kafka consumer configuration and relevant DEBUG logs, with credentials and connection strings redacted.

    References:

    If my answer helped you, please consider marking it as accepted. This helps others in the community find similar solutions.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.