ApexSharp Functions
C# (Microsoft .NET) Server Side SDK for Salesforce Functions
Last updated
C# (Microsoft .NET) Server Side SDK for Salesforce Functions
Last updated
Please note that this project is not yet available to the public because
Currently, in alpha, this is just a proof-of-concept showing how Salesforce Functions can support C# on the server side and also various hosting option, not just Heroku
Although I work on these types of projects on my own time, Salesforce OSS legal must approve them before they can be made public, as Salesforce still employs me
If you have questions or comments, you can reach me on
Goal
Provide a Cloud vendor agnostic C# based server-side SDK for Salesforce Functions that is compatible with the open
Open-source tools used in this project
/
The client Apex code has a very simple open API. This allows Salesforce to call the client API from Apex, LWC, Flow, and Flow for Industry (Omniscript, Integration Procedure, Flex cards). Currently, the Apex API we provide allows 1:1 mapping with the current implementation.
The C# SDK can be used with .Net supported provider. Following is a list of providers we are testing.
Heroku.
Net Core using Buildpacks
Connect to Heroku Postgres, Radis, and Apache Kafka, as all of them have C# drivers
For dealing with large-scale Salesforce data, use Heroku Connect
Amazon AWS
Microsoft Azure
: This event-driven serverless service is the easiest option with zero management and automatic scalability.
: Easy to use Web API hosting service.
and
(How about 400 CPU Cores and 10 TB of Ram on a single PC)
FPGA acceleration for Azure, using for C# binding
; all these services provide C# SDK; thus, you can extend your server-side functions to use these services.
Google Cloud
Any Kubernetes Container providers such as AWS, Azure, GCP, , and
Raspberry Pi. allows you to build IoT devices that Salesforce can communicate with
Functions can be deployed to edge service providers such as as they support Paketo buildpacks
GPU-optimized virtual machine for your AI / ML needs. Use services such as
for advanced math
for Machin Learning, including Open A
Your Datacenter or Desktop with Windows, Linux, or Mac. Useif you are behind a firewall.
Advantages of ApexSharp Functions C# SDK over Salesforce Functions
Open source, which means it's free.
The SDK can run anywhere. .NET is supported.
In addition to 1:1 request-reply and 1:1 callbacks, the SDK supports 1:M callbacks.
Open standards allow it to work with any type of client, not just Salesforce.
The world has a large pool of C# developers.
The server SDK is Net Core; thus, languages such as F# and Visual Basic can be used.
Visual Studio is the most advanced IDE in the mark
Advantages of Salesforce Functions on Heroku
Salesforce functions is a managed service product offering. Heroku takes care of everything from hardware to software to security and uptime.
Enterprise customers prefer to buy from Salesforce and not use open-source software.
Enterprise customers like dealing with one vendor for Salesforce Functions from the business and technical side.
How Salesforce functions communicate to Heroku is internal to Salesforce. From a network view, Salesforce and Heroku can be considered a single network, thus providing lower latency and an extra security layer.
While SF does not count outgoing API calls, they set limits on incoming REST calls. Function calls inbound REST API for CRUD and Callbacks. Salesforce can remove this limit for customers who are using Heroku. Note: This issue will go away with API user licenses being standard. I am testing more to see the overall limitations of REST calls inbound and outbound now.
How it all works
ApexSharp contains two parts, client SDK and server SDK. The client SDK is Apex, and it runs on your Salesforce org. You can call the client using Apex, LWC, Flow, or Flow for Industry.
The server SDK is developed C# that is compatible with any .NET languages and runs on any environment where you can run .NET Core.
Apex Client SDK
Original Salesforce Functions Code
Modified Code to work with ApexSharp Functions
As you see, all we have to do is to remove the "functions." namespace from your existing code.
For example
functions.Function accountFunction = functions.Function.get('MyProject.AccountFunction');
Turns to
Function accountFunction = Function.get('MyProject.AccountFunction');
A simple search and replace can do it.
LWC, Flow, Flow for Industry
A UI-less LWC SDK is in the works, which can be used on Salesforce pages, Flow, and Flow for Industry.
Server Side SDK
The primary services provided by the SDK are
Support for Salesforce Functions API specification.
1-1 Request Reply support.
1-1 and 1-M callback support.
Detail Logging
User-defined Security
Access to Salesforce objects through Rest API to perform CRUD
Execute Apex on Salesforce using Tooling API
0MQ support for interoperability with other programming languages
Realtime monitoring of functions that are executing
Web Assembly on Server
Serverless Applications developed using multiple languages can be compiled into a single image.
The small size allows it to be run on IoT devices
All the edge-based serverless vendors support Web Assembly
Demo and Current Status
Currently, I have a few very simple demos running on Microsoft Azure and a Salesforce developer sandbox.
Demo 1: Request-Reply: PDF Creation
In this demo, I pass some data from Salesforce to the C# Server function running on an Azure App Service instance. This server-side code takes the data and
Call the server-side code using Apex Functions, and pass an Order ID from the Order object.
C# Server will make CRUD calls to Salesforce and read the rest of the details.
Uploads the PDF to a CDN
Returns a secure URL link of the PDF to Salesforce.
Salesforce shows the generated PDF in an LWC
With the click of a button, the PDF can be emailed to someone, again using server-side functions.
Demo 2: Call Back: FTP Download and Upload.
The primary purpose of this demo is to show 1-M callbacks. Here is how it works
Salesforce calls the Function with FTP server info and Amazon S3 server info. Also, the list of the filename to download
While the server does the download and uploads, every 10%, it will make a call back to Salesforce to inform the progress.
This detail can be real-time in realtime in LWC using Platform events.
My primary concentration now is to show how the server code can be deployed on multiple environments. Here is the list I am working on and the status.
Use different cloud providers, from ARM-based CPU to a
The can be overcome since you are in control.
C# has a very large 3rd party library support, over 350K packages on
C# apps can call Node.Js code in-process using different
Allows Client and Server to be developed locally using to develop Apex code locally.
Ability to scale the cloud services (1 CPU Cores to ) or use Kubernetes for unlimited scalability.
Integrate with applications written in other programming languages using ZeroMQ has support for all 30 different programming languages.
Centralized logging, Salesforce, and Apex Functions log combined on
We are using and
Salesforce has the freedom to optimize the connectivity between SF and Heroku. For example, use tools such as .
The Apex code runs in your Salesforce environment and implements all the . If you have existing Salesforce Apex code for functions, you will only need to make very small modification
The Server SDK is a .NET Nuget package and Open Source C# code based on , which has become a Salesforce-approved open-source project.
Integration with using grpC
A lot of work is happening in running applications on a Web Assembly container that supports . Currently, I am working with The biggest advantage of Web Assembly is
Creates an Invoice PDF using (An amazing open-source PDF creation tool)
(Done)
Heroku using Net Core Buildpacks
Kubernetes Container providers such as
Dedicated Server on an ultralow cost dedicated service provider. 20 Cores and 192 GB of ram for about 150$/Month.