0

We have an HttpTriggred function according to the following code snippet:

[FunctionName("commandcompleted")]
public static Task SendMessage(
  [HttpTrigger(AuthorizationLevel.Function, "post", Route = "commandcompleted/{userId}")]
  object message,
  string userId,
  [SignalR(HubName = Negotitate.HubName)]IAsyncCollector<SignalRMessage>
  signalRMessages,
  ILogger log)
  {
        return signalRMessages.AddAsync(
                new SignalRMessage
                {
                    UserId = userId,
                    Target = "CommandCompleted",
                    Arguments = new[] { message }
                });
    }

The client app which is, in fact, a signalR client receives a notification upon completion an operation once the mentioned trigger is invoked.

It's observed that the payload received by the client app is always in Pascal Case. How can we augment the function's code so that it broadcasts the payload in camel case format? Please note that decorating the object's properties by [JsonProperty("camelCasePropertyName")] is not an option and we'd like to do away from it.

Arash
  • 3,628
  • 5
  • 46
  • 70

2 Answers2

1

The application tier which prepares message object must take care of serializing it in camel case format before submitting it to the http-triggered function.

Arash
  • 3,628
  • 5
  • 46
  • 70
1

I managed to create Camel Case responses by setting the following configuration:

public class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder) =>
        builder.Services.AddLogging().Configure<SignalROptions>(o =>
        {
            o.JsonObjectSerializer = new NewtonsoftJsonObjectSerializer(new JsonSerializerSettings()
            {
                ContractResolver = new DefaultContractResolver()
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                }
            });
        });
}

Help got from this Thread:

How to configure underlying JSON serialization options for Azure SignalR Management library?

Alex Cr
  • 431
  • 5
  • 8