使用流分析将数据从 IoT 中心传输到 Cosmos DB 会出现分区错误

Using Stream Analytics to transfer data from IoT Hub to Cosmos DB gives partition error

我想使用流分析将数据从我的 IoT 中心传输到 Cosmos DB 和存储 table。存储 table 正常。但是,我的流分析在 activity 日志中给出了以下数据转换错误:

"The output record does not contain the column 'deviceId' (case-sensitive) to use as the partition key property. By default, Azure Stream Analytics retries writing the event indefinitely until the write succeeds. Consider choosing Drop Output Error Policy to skip such errors, so an error wouldn't block the job progress.. Error encountered after writing [0] batches."

deviceId 是我在 cosmos 数据库中的分区键。我可以看到数据正在正确进入流分析。这是输入示例:

[{"deviceId":1,"dateStamp":"2019-03-27T18:55:43.3546682Z","temperature":6.510664596692969,"EventProcessedUtcTime":"2019-03-27T18:58:41.6172586Z","PartitionId":1,"EventEnqueuedUtcTime":"2019-03-27T18:55:43.3450000Z","IoTHub":{"MessageId":null,"CorrelationId":null,"ConnectionDeviceId":"Simulator","ConnectionDeviceGenerationId":"636891216524279053","EnqueuedTime":"2019-03-27T18:55:43.3370000Z","StreamId":null}},
{"deviceId":1,"dateStamp":"2019-03-27T18:56:43.3809346Z","temperature":5.5680961758215428,"EventProcessedUtcTime":"2019-03-27T18:58:41.6172586Z","PartitionId":1,"EventEnqueuedUtcTime":"2019-03-27T18:56:43.3640000Z","IoTHub":{"MessageId":null,"CorrelationId":null,"ConnectionDeviceId":"Simulator","ConnectionDeviceGenerationId":"636891216524279053","EnqueuedTime":"2019-03-27T18:56:43.3690000Z","StreamId":null}},
{"deviceId":1,"dateStamp":"2019-03-27T18:57:43.4122929Z","temperature":5.07182001605249,"EventProcessedUtcTime":"2019-03-27T18:58:41.6172586Z","PartitionId":1,"EventEnqueuedUtcTime":"2019-03-27T18:57:43.4050000Z","IoTHub":{"MessageId":null,"CorrelationId":null,"ConnectionDeviceId":"Simulator","ConnectionDeviceGenerationId":"636891216524279053","EnqueuedTime":"2019-03-27T18:57:43.4010000Z","StreamId":null}}]

我的 SQL API 查询如下,ColdStorageSmartFridge 是存储 table 而 HotStorageSmartFridge 是 cosmosdb:

SELECT
    deviceId,
    dateStamp as time,
    temperature
INTO
    [ColdStorageSmartFridge]
FROM
    [IoTHubSmartFridge]

SELECT 
    deviceId,
    dateStamp,
    temperature    
INTO
    [HotStorageSmartFridge]
FROM
    [IoTHubSmartFridge]

我已经为此工作了整个下午,但无法正常工作。我错过了什么?

您的分区键似乎区分大小写。以前 Azure 流分析将不同的字段小写。虽然这不是预期的行为,但我们不想在服务中引入重大更改,因此在“compatibility level 1.1”下发布了修复程序。

能否尝试将作业兼容级别更改为 1.1,如果它能解决您的问题,请告诉我。

我们将在不久的将来更改默认的兼容级别。