我收到的错误与我在查询中发送的错误不匹配。
我的查询:
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]
这是导出配置:
我尝试将 DocumentId 属性设置为 DocumentId
或 id
,但没有成功。我什至在结果中添加了额外的 ID、DocumentId 和 PartitionKey 字段,只是为了保存一些内容,但没有成功(还尝试单独运行将 id 或 DocumentId 放入 CosmosDB Document Id 属性中。无法保存任何内容...
我返回的错误是:
为 DocumentDB 准备数据时发生错误。输出记录不包含 DocumentDB 用作分区键属性的 DocumentId 列
最佳答案
DocumentDB 提示您已将集合的分区键配置为 DocumentId
,但输出中没有此类列。我发现当我在 ASA 中为列添加别名时,输出中的列名称以小写结尾...
ASA 不关心这种情况,但 DocumentDB 会关心。尝试创建一个新集合,并将分区键设置为 documentid
。您可以在 docdb 门户的“设置”下查看当前 key 。
注意 ASA 输出属性中的文档 ID
控制 id
字段中的内容。它可能与您在 DocumentDB 中分区所依据的字段不同。例如,在我的一项工作中,我想通过 deviceID
组织数据库,但根据 messageType
识别文档。因为我必须为 deviceID
指定别名,所以它会丢失大写字母,并且我必须将分区键设置为 deviceid
。然后我将我的 Document id
设置为 messageType
:
我得到的文档如下所示:
{ "deviceid": "我的设备标识符", /.../, "id": "我的消息类型" }
关于azure - 将分析流式传输到 CosmosDB 总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46814183/