azure - 将数据从函数提取到事件中心、Azure 数据资源管理器?

标签 azure azure-eventhub azure-data-explorer

我有一些 JSON 数据进入 IOT 中心,然后触发一个函数来取消数据的嵌套。

该函数将此数据发送到事件中心,然后 Azure 数据资源管理器应该根据我设置的映射来摄取数据。

问题是没有数据进入数据浏览器;它通过映射接收数据的唯一方法是将源设置为通过自定义路由接收信息的事件中心。

是否可以通过 IOT 中心 -> 功能 -> 事件中心的方式在数据浏览器中提取数据?

编辑:

用于取消嵌套并将数据转发到另一个事件中心的函数:

module.exports = async function (context, eventHubMessages) {

    // receive message from IOT hub
    eventHubMessages.forEach((message, index) => {
        var devicename = message.deviceName;
        // timestamp comes in two different texts, find and store correct one
        var timestamp = (message.timestamp == null) ? message.timeStamp : message.timestamp;
        //context.log("Message: " + JSON.stringify(message));
        if (message.tags != null) {
            message.tags.forEach((tag, index) => {
                // for each tag, create new object
                var name = tag.Name;
                var value = tag.Value;
                var newObject = {
                                 "name":name,
                                 "value": value,
                                 "eventenqueuedutctime": timestamp,
                                 "devicename": devicename
                                }                
                // output message object to 'splitmessage-dev' event hub
                context.bindings.outputEventHubMessage = newObject
                context.log("Sent object: " + JSON.stringify(newObject));
            })
        }
    });

};

我可以确认其他事件中心正在接收此数据(使用打印传入消息的另一个函数进行检查)。

映射如下所示:

'testTableMap' '[{"column":"name", "path":"$.name"}, 
{"column":"value", "path":"$.value"}, 
{"column":"eventenqueuedutctime", "path":"$.eventenqueuedutctime"},
{"column":"devicename", "path":"$.devicename"}]'

最佳答案

应该可以使用您提供的设置来提取数据。

由于数据没有被摄取,您可能应该尝试诊断它被卡住的地方。

我将提供一些有助于调试的一般准则。

数据未到达配置为 ADX 数据源的 EventHub

您可以检查 EventHub 监控并验证事件是否正在流动。 另外,我建议从 EventHub 读取数据,以确保它看起来像您所期望的那样。 (看来您已经这样做了)

这里的情况似乎并非如此,因为您已经明确表示您确实看到事件流入 EventHub,并且您可以通过另一个函数成功读取它们。

表/映射未正确配置

尝试从配置的 EventHub 提取数据 manually

// create table 
// I am assuming strings because other types can cause format errors, 
// so I would try strings before other specific types (dynamic, datetime)
.create table IngestionTest (name: string, value:string, eventenqueuedutctime:string, devicename:string)

// add mapping
.create table IngestionTest ingestion json mapping 'testTableMap' '[{"column":"name", "path":"$.name"}, {"column":"value", "path":"$.value"}, {"column":"eventenqueuedutctime", "path":"$.eventenqueuedutctime"},{"column":"devicename", "path":"$.devicename"}]'

// ingest data manually - replace with you actual data
.ingest inline into table IngestionTest with (jsonMappingReference='testTableMap') <| '{ "name" : "test", "value": { "some":"nested", "value": true}, "eventenqueuedutctime" : "2016-01-14", "devicename": "surface" }'

如果以上方法不起作用,您可以尝试通过 listing ingestion errors 来了解原因

.show ingestion failures

如果上述方法有效,您可以尝试使用其他数据类型。

数据源监控

您可以通过 Azure 门户检查的另一件事是 ADX 集群的指标。

尝试转到 Azure 门户中的集群,在Metrics 选项卡中,您可以选择两个可以帮助您排除故障的指标:

已处理的事件 - 让您了解 ADX 设法从 EventHub 读取的事件数量。这基本上可以让您知道数据源配置正确。如果您没有看到任何事件,我建议您设置一个新的来源。

摄取结果 - 为您提供摄取状态(成功/失败)的计数,这也可以帮助诊断故障。

关于azure - 将数据从函数提取到事件中心、Azure 数据资源管理器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55945077/

相关文章:

c# - 来自 Azure TableStorage 的 TableQuery<T>,根据 PartitionKey 进行筛选

azure - 使用 Azure Log Analytics 搜索存储帐户

azure-data-explorer - 是否可以使用 Kusto 查询语言创建直方图?

azure - 如何创建 Azure Kusto 查询以仅在应用程序见解上按客户端操作系统名称(操作系统版本已删除)进行分组?

azure - 如何从azure存储帐户文件夹获取所有文件和文件夹,压缩并上传到node js中的其他blob存储

sql-server - Sql Azure - 单独的服务器?

azure - 可以在 Azure 流量管理器上配置警报吗?

azure - 高吞吐量发送到 EventHubs 导致 MessagingException/TimeoutException/服务器无法处理请求错误

node.js - 我们如何将消息从特定事件中心分区获取到 azure 函数中,以及如何自动扩展 azure 函数的数量?

azure - 在Azure databricks中,将pyspark数据帧写入eventhub花费的时间太长,因为数据帧中有300万条记录