title: How does Azure's EventData.PartitionKey decide which partition to write to?
body: <p>I am trying to implement an Event Hub in Azure. I have managed to create a Producer which publishes messages to the Event Hub, as well as a Consumer which reads them off. My Event Hub is divided up into 16 partitions. On the consumer side, I loop through each of these as follows:</p>
  
  <pre><code>var eventHub = NamespaceManager.CreateFromConnectionString(builder.ToString()).GetEventHub("de-analytics-events");
  
  foreach (var partitionId in eventHub.PartitionIds)
  {
       subscriberGroup.RegisterProcessor&lt;EventProcessor&gt;(new Lease
       {
           PartitionId = partitionId
       }, new EventProcessorCheckpointManager());
  
       Console.WriteLine("Processing: " + partitionId);
  }
  </code></pre>
  
  <p>Looking at these values in a debugger shows that the <code>eventHub.PartitionIds</code> range from "0" to "15" in the case of 16 partitions.</p>
  
  <p>However, on the producer side, all I was allowed to specify was my <code>EventData.PartitionKey</code>, which is a string, but which does not directly correspond to the strings on the consumer side. E.g. if I specified a PartitionKey = "7", it did not necessarily write to partition "7". </p>
  
  <p>Reading up shows that some sort of hashing is involved, but I don't particularly want to guess randomly at 16 strings that hash to the numbers 0-15. So I'm wondering how I can define which partition is published to?</p>
  
  <p>For added reference, <a href="http://alexandrebrisebois.wordpress.com/2014/07/18/getting-acquainted-with-azure-service-bus-event-hubs/" rel="noreferrer">this</a> is the tutorial I followed to get my simplest case working.</p>