Search code examples
c#azureazure-eventhub

How do I debug Azure EventHubs?


I am trying to send data to an azure event hub later to be consumed by stream analytics and PowerBI.

My C# application is sending a simple test string (JSON formatted) while I am testing the Event Hub, but when I want to process the data in the event hub it tells me no data has been sent.

I am unsure how to debug the hub to see why the message does not show up, I tried google for a debug document but found none when searching for debugging azure event hubs

How can I find any error messages about this?

My C# code is simplified like this for testing purposes

private async Task SendMessageToEventHub(string messageToSend)
{
    var connectionStringBuilder = new EventHubsConnectionStringBuilder(EventHubConnectionString)
    {
        EntityPath = EventHubName
    };

    eventHubClient = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

    try
    {
        await eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(messageToSend)));
    } catch (Exception exception) {
        _logger.LogInformation($"-PimLog- -ProductInfoController- {DateTime.Now}, > Exception: {exception.Message} ");
    }

    _logger.LogInformation($"-PimLog- -ProductInfoController- {DateTime.Now}, EventHub Message Sent Successfully ");
}

I do see the log message that Message Sent Successfully so no obvious error is there.

When I try and run the query in the azure portal I get the following message

There is no data from input 'pimhub'. Please make sure the input source has data and then try again.

How can I debug further?


Solution

  • In order to view data using an Azure Stream Analytics query you must first Deploy the query.

    Azure Stream Analytics Query

    Once you've done this you need to open the query and set a time range for the sample data you want to query by clicking: "Select time range".

    Azure Stream Analytics - Select Time Range

    You should now be able to query your data using the query tool.

    Azure Stream Analytics - Query Restults