I have tried many options.
My Message Routing Custom Endpoint is set up in the Azure Portal. I use a partition key template as follows:
{deviceid}-{my_telemetry_date}
, so that I can achieve a partition key with the following example value:
{"PartitionKey" : "FFFFFFFA-2023-10-22"}
where the {"my_telemetry_date" : "2023-10-22"}
I have tried the following syntaxes:
{deviceid}-{Body.my_telemetry_date}
but results in:
{"PartitonKey" : "FFFFFFFA-{Body.my_telemetry_date}"}
{deviceid}-{Body.<my_telemetry_date>}
but results in:
{"PartitonKey" : "FFFFFFFA-{Body.<my_telemetry_date>}"}
{deviceid}-{<my_telemetry_date>} but results in:
{"PartitonKey" : "FFFFFFFA-{<my_telemetry_date>}"}
{deviceid}-<my_telemetry_date>
but results in:
{"PartitonKey" : "FFFFFFFA-<my_telemetry_date>"}
I need to append the Date contained in the telemetry data field my_telemtry_date onto the {deviceid}-
The {deviceid} is properly substituted, but cannot find any info on proper syntax to substitute a telemetry field's value in the Partition key template.
Unfortunately, you can't include telemetry values in your partition key using the built-in features of IoT Hub. The partition key only allows certain values per the docs:
If you need telemtry values to be part of the partition key, you will first need to route the message somewhere else (e.g. Azure Function) and from there pluck out the value and pass it to CosmosDB.