Json Serialization fails with FunctionInputConverterException for complex types in Durable function

Viewed 29

I am creating a durable function for Azure Functions (.NET 6 out-of-process). I get errors when passing complex types from orchestrator to activity.

It appears the TaskOrchestrator and the TaskActivity have different JSON serialization configurations that are not compatible.

When using complex types, the orchestrator serializes them with {"$type":"**TypeName**",...} but that syntax is not supported for arrays in the the TaskActivity deserialization so it fails with JsonException.

Cannot get the value of a token type 'StartObject'

I have created a sample project which demonstrates the issue.

https://github.com/ulvesked/DurablePocoPayloadSample

System.Text.Json.JsonException: 'The JSON value could not be converted to System.Byte[]. Path: $.Items[0].Image | LineNumber: 0 | BytePositionInLine: 155.'

EDIT: Found that the orchestrator internally uses Newtonsoft.Json to replay messages. That is what causes the incompatibility. I have created a github issue here: https://github.com/Azure/durabletask/issues/796

0 Answers
Related