PartitionKey in Stream Analytics and Event Hubs
Hello,
I'm trying to learn more about event hub partitions. I'm running a simple .Net program to send 20 events to an Event Hub with 3 partitions. I then query the events with the input preview in stream analytics. The simple .Net program is following:
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Producer;
var connectionString = "Endpoint=sb://eventhubsnamespace321.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=";
var eventHubName = "";
var producer = new EventHubProducerClient(connectionString, eventHubName);
try
{
var eventBatch = new List<EventData>();
for (var counter = 0; counter < 20; ++counter)
{
var eventBody = new BinaryData($$"""{"numCars": {{new Random().Next(50)}}, "highway": {{counter%3}}}""");
var eventData = new EventData(eventBody);
eventBatch.Add(eventData);
}
await producer.SendAsync(eventBatch, new SendEventOptions() {PartitionKey = "highway"});
}
catch(Exception ex)
{
Console.WriteLine($"exception occured {ex}");
}
As you can see the Event Hub name is "highway2. I'm sending two columns (in Json) of "numCars" and "highway". The "highway" is either 0, 1, or 2 for the three different partitions. I set the PartitionKey in the SendEventOptions. In Event Hubs I have 3 partitions:
Now, I connected the Stream analytics job to the Event Hub and only seeing one partition for the PartitionId:
Shouldn't the PartitionId be different for each highway since the PartitionKey is set to highway?
Thanks!