流分析到CosmosDB总是失败

时间:2017-10-18 15:43:27

标签: azure azure-cosmosdb azure-stream-analytics

我收到的错误与我在查询中发送的内容不符。

我的查询:

SELECT
    udf.CreateGuid('') AS [id],
    udf.CreateGuid('') AS [DocumentId],
    BlobName,
    BlobLastModifiedUtcTime,
    [telmetry].[event_type] as PartitionKey,
    -- webhook
    [telmetry].[id] AS [hook_id],
    [telmetry].[event_version],
    [telmetry].[create_time],
    [telmetry].[resource_type],
    [telmetry].[event_type],
    [telmetry].[summary],
    [telmetry].[resource],
    [telmetry].[links]
INTO
    [cosmosdb2]
FROM
    [telemetrydepot] AS [telmetry]
TIMESTAMP BY [telmetry].[create_time]

这是导出配置:

enter image description here

我尝试将DocumentId属性设置为DocumentIdid但没有成功。我甚至在结果中添加了额外的ID,DocumentId和PartitionKey字段,只是为了得到保存但没有成功的东西(也尝试将id或DocumentId放在CosmosDB文档Id属性中的单独运行。无法保存任何东西......

我回来的错误说:

An error occurred while preparing data for DocumentDB. The output record does not contain the column DocumentId to use as the partition key property by DocumentDB

1 个答案:

答案 0 :(得分:3)

DocumentDB抱怨您已将集合的分区键配置为DocumentId,但输出中没有此列。我发现当我在ASA中对列进行别名时,输出中的列名最终为小写...

ASA并不关心此案,但DocumentDB会这样做。尝试创建分区键设置为documentid的新集合。您可以查看"设置"下的当前密钥。在docdb的门户网站中。

注意ASA输出属性中的Document id控制id字段中的内容。它可能与您在DocumentDB中分区的字段不同。例如,在我的一个工作中,我想按deviceID组织数据库,但根据messageType识别文档。因为我必须使用别名deviceID,所以它会丢失大写字母,我必须将分区键设置为deviceid。然后我将Document id设置为messageType

enter image description here

enter image description here

我得到的文件看起来像这样:

{   " deviceid":" MyDeviceIdentifier",   /.../,   " id":" MyMessageType" }