Search code examples
azureazure-eventhub

Eventhub partition key in connection string


What's the correct way to write an eventhub connectionstring with the partition key (or publisher)? I should write the partition inside the EntityPath? Could someone give me an example? Also, is there a method to link a consumergroup to a specific partition?


Solution

  • It should be something like below,

     /// <param name="connectionString">EventHub connection string with format: Endpoint=sb://namespace_DNS_Name;SharedAccessKeyName=SHARED_ACCESS_KEY_NAME;SharedAccessKey=SHARED_ACCESS_KEY;EntityPath=.</param>
    

    You dont have to put the paritionKey in the connection string, it can be send with the data as follows,

    var partitionSender = this.EventHubClient.CreatePartitionSender(partitionId);