Using C# to create Realm functions

Our team is 99% C# oriented. We are super productive building backends with C#. Even though realm functions are pretty powerful, they have a major drawback - they are JavaScript. Our performance is pretty awful in JavaScript. We were thinking about ways of how we could utilize our C# expertise in building realm functions instead of using JavaScript.
Well, the best way would have been if Realm Functions supported C# code out of the box. I guess that’s not a reality either now or in the near future right?
The second way I was thinking is using realm functions as a proxy to our C# custom backend that would use Realm.NET to get the job done. However, there are some things that I am not quite sure about.

  1. The architecture I was thinking about is each function would basically do an HTTP call to the corresponding API in our backend and forward the result to the calling user. Does this sound like a good strategy?
  2. Latency - let’s say we use MongoDB Atlas on Azure infra. We deploy our code in the same azure region and infra (probably an app service or Azure functions), I wonder if that’s going to be fine or no. Perhaps the answer to this question is just go ahead and try. If the latency is acceptable then go for it. But I would really love to know if someone has already done something similar
  3. Will I be able to achieve everything possible using JS functions using .NET SDK? Considering how implicit JS is, and how explicit .NET is, will I face any issues in terms of data contract incompatibilities?
1 Like

One option is that you could run your C# code in AWS Lambda functions and then execute them via the AWS service that’s built into Realm. https://docs.mongodb.com/realm/services/aws/

2 Likes

@Andrew_Morgan thanks for the reply. All of our infrastructures are in Azure. And we are planning to use Azure managed Atlas instance to host the Realm cloud. I would imagine using Azure functions instead of AWS lambdas would result in similar results? Which SDK should I use to communicate to the Realm cloud in the backend? The same SDK as in mobile? Are there any backend-specific SDKs?

You can see the available MongoDB Realm SDKs here… https://docs.mongodb.com/realm/sdk/dotnet/ As you can see, there’s only one .Net SDK, and so you’d stick with that one.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.