Azure 数据资源管理器不存储 json

问题描述 投票:0回答:1

我在 Azure 数据资源管理器数据库中有一个表,其定义如下:

.create table GetPrice (lpname: string, TimeUTC: datetime, base_volume: real, highest_bid: real, currency_pair: string, price: real, lowest_ask: real, change_percentage: real, quote_volume: real, high_24h: real, low_24h: real, EventProcessedUtcTime: datetime, current_time: datetime, ['guid']: string, epochtime: int, time_ms: real, channel: string, event: string)

我从外部 API 获取对象并将其解析为 JSON,结果如下:

{
    {
        "Time": 0,
        "Time_ms": 0,
        "Channel": "external",
        "event": "update",
        "Result": {
            "currency_pair": "BABA",
            "last": "0",
            "lowest_ask": null,
            "highest_bid": "71.93",
            "change_percentage": "0",
            "base_volume": "97",
            "quote_volume": null,
            "high_24h": "0",
            "low_24h": "0",
            "GUID": "<GUID>"
        },
        "TimeUTC": "2024-04-10T10:13:13.1732158Z",
        "LPName": "NAME",
        "Error": {
            "Code": 0,
            "Message": null
        }
    }
}

问题:在 GetPrice 表中仅存储 TimeUTC、LPName、EventProcessedUtcTime 和 current_time。

我不完全理解为什么,好像嵌套的

Result
对象存在问题,那么
Channel
event
也应该填充,但它们没有。

我尝试在将

Result
发送到 EventHub 之前将其压平,但这也不起作用。另外,我尝试创建一个新表并将数据传递到那里,但这也失败了。

我正在使用

Azure.Messaging.EventHubs
库与 ADX 连接和通信。

欢迎任何线索或建议。

azure azure-eventhub azure-data-explorer
1个回答
0
投票

TimeUTC
LPName
EventProcessedUtcTime
current_time
存储在
GetPrice
表中的原因是该区域中存在资源组,并且触发了与该资源组相关的事件时间。解决此问题的一种方法是更改资源位置。

// Create mapping command


.create table ['ravi'] ingestion json mapping 'ravi_mapping_1' '[{"column":"topic", "Properties":{"Path":"$[\'topic\']"}},{"column":"subject", "Properties":{"Path":"$[\'subject\']"}},{"column":"eventType", "Properties":{"Path":"$[\'eventType\']"}},{"column":"id", "Properties":{"Path":"$[\'id\']"}},{"column":"data", "Properties":{"Path":"$[\'data\']"}},{"column":"dataVersion", "Properties":{"Path":"$[\'dataVersion\']"}},{"column":"metadataVersion", "Properties":{"Path":"$[\'metadataVersion\']"}},{"column":"eventTime", "Properties":{"Path":"$[\'eventTime\']"}}]'



// Create table command



.create table ['ravi'] (['topic']:string, ['subject']:string, ['eventType']:string, ['id']:guid, ['data']:dynamic, ['dataVersion']:string, ['metadataVersion']:long, ['eventTime']:datetime)
  • 使用 Kusto Azure Data Explorer 使用 .net 提取数据

  • 使用 .NET 向 Azure 事件发送或接收事件 集线器

注:

Azure.Messaging.EventHubs
仅用于连接事件中心,
Microsoft.Azure.Kusto.Ingest
用于连接到 Azure 数据资源管理器。将数据从事件中心提取到 Azure Synapse Data Explorer 的一种方法。另一种方法是使用 Azure Synapse Data Explorer 从事件中心获取数据 (或者) 使用分析事件中心实例中的数据通过 Azure 数据资源管理器分析事件数据。

enter image description here

enter image description here

Azure 数据资源管理器: 我为此示例数据创建了一个表和映射命令

[
    {
        "currency_pair": "BABA",
        "last": "0",
        "lowest_ask": null,
        "highest_bid": "89.93",
        "change_percentage": "10",
        "base_volume": "197",
        "quote_volume": null,
        "high_24h": "0",
        "low_24h": "0",
        "GUID": "<GUID>",
        "nestedKey": {
            "nestedKey1": "nestedValue1"
        },
        "arrayKey": [
            "arrayValue1",
            "arrayValue2"
        ]
    }
]

// Create table command



.create table ['teja'] (['currency_pair']:string, ['last']:long, ['lowest_ask']:string, ['highest_bid']:real, ['change_percentage']:long, ['base_volume']:long, ['quote_volume']:string, ['high_24h']:long, ['low_24h']:long, ['GUID']:string, ['nestedKey']:dynamic, ['arrayKey']:dynamic)



// Create mapping command



.create table ['teja'] ingestion json mapping 'teja_mapping' '[{"column":"currency_pair", "Properties":{"Path":"$[\'currency_pair\']"}},{"column":"last", "Properties":{"Path":"$[\'last\']"}},{"column":"lowest_ask", "Properties":{"Path":"$[\'lowest_ask\']"}},{"column":"highest_bid", "Properties":{"Path":"$[\'highest_bid\']"}},{"column":"change_percentage", "Properties":{"Path":"$[\'change_percentage\']"}},{"column":"base_volume", "Properties":{"Path":"$[\'base_volume\']"}},{"column":"quote_volume", "Properties":{"Path":"$[\'quote_volume\']"}},{"column":"high_24h", "Properties":{"Path":"$[\'high_24h\']"}},{"column":"low_24h", "Properties":{"Path":"$[\'low_24h\']"}},{"column":"GUID", "Properties":{"Path":"$[\'GUID\']"}},{"column":"nestedKey", "Properties":{"Path":"$[\'nestedKey\']"}},{"column":"arrayKey", "Properties":{"Path":"$[\'arrayKey\']"}}]'

enter image description here

确保在表/表映射

命令
中添加
Channel
event等。

© www.soinside.com 2019 - 2024. All rights reserved.