I'm migrating Azure Functions v3 from Newtonsoft.Json to System.Text.Json and trying to get camelCase working globally.
For these:
- SignalR
- Service Bus output bindings
- Cosmos DB
I was able to explicitly pass JsonSerializerOptions or set it globally (SignalR) but I'm not able to do so for IAsyncCollector.
Here is my code:
[FunctionName(nameof(SampleFunction))]
public async Task Run(
[ServiceBusTrigger(ServiceBusQueue.QueueA)] string json,
[ServiceBus(ServiceBusQueue.QueueB)] IAsyncCollector<Delivery> queueB,
[ServiceBus(ServiceBusQueue.QueueC)] IAsyncCollector<Driver> queueC,
ExecutionContext context)
{
// ... do some work
await queueB.AddAsync(objectB).ConfigureAwait(false);
// ... do some more work
await queueC.AddAsync(objectC).ConfigureAwait(false);
}
objectB and objectC ends up in service bus not with camel case. As a workaround I'm setting property names as case insensitive on the receiving function.
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PropertyNameCaseInsensitive = true
Any idea how can I get IAsyncCollector to serialize with camel case?