如何调试 Azure EventHub?

Mat*_*han 5 c# azure azure-eventhub

我试图稍后将数据发送到 azure 事件中心以供流分析和 PowerBI 使用。

当我测试事件中心时,我的 C# 应用程序正在发送一个简单的测试字符串(JSON 格式),但是当我想要处理事件中心中的数据时,它告诉我没有发送任何数据。

我不确定如何调试集线器以查看为什么消息不显示,我尝试在 google 上查找调试文档,但在搜索调试 azure 事件集线器时没有找到任何内容

我如何找到与此相关的任何错误消息?

为了测试目的,我的 C# 代码被简化为这样

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 ");
}
Run Code Online (Sandbox Code Playgroud)

我确实看到了“消息发送成功”的日志消息,因此没有明显的错误。

当我尝试在天蓝色门户中运行查询时,我收到以下消息

There is no data from input 'pimhub'. Please make sure the input source has data and then try again.
Run Code Online (Sandbox Code Playgroud)

如何进一步调试?

小智 0

为了使用 Azure 流分析查询查看数据,您必须首先部署查询。

Azure 流分析查询

完成此操作后,您需要打开查询并通过单击“选择时间范围”为要查询的示例数据设置时间范围。

Azure 流分析 - 选择时间范围

您现在应该能够使用查询工具查询数据。

Azure 流分析 - 查询结果