I have a trouble saving telemetry that are coming from Azure IoT hub to Cosmos DB. I have the following setup:
- IoT Hub - for events aggregation
- Azure Stream Analytics - for event stream processing
- Cosmos DB with Table API. Here I created 1 table.
The sample message from IoT Hub:
{"id":33,"deviceId":"test2","cloudTagId":"cloudTag1","value":24.79770721657087}
The query in stream analytics which processes the events:
SELECT
concat(deviceId, cloudtagId) as telemetryid, value as temperature, id, deviceId, 'asd' as '$pk', deviceId as PartitionKey
INTO
[TableApiCosmosDb]
From
[devicesMessages]
the proble is following every time the job tries to save the output to CosmosDB I get an error An error occurred while preparing data for DocumentDB. The output record does not contain the column '$pk' to use as the partition key property by DocumentDB
Note: I've added $pk
column and PartitionKey
when trying to solve the problem.
EDIT Here, is the output configuration:
Image may be NSFW.
Clik here to view.
Does anyone know what I'm doing wrong?