I had a meeting the other day with an Oracle Partner and the discussion was about serverless solutions and Oracle Functions was introduced. And the natural question to ask was, “What is your preferred language?”.
They answered, “Mostly PHP. We also use C#”.
I had to think a little. And navigating to the fnproject.io (the open-source project that Oracle Functions is based upon), it was clear that C# was supported. Here’s a quick tour through that experience.
A couple of quick points:
- I didn’t need to install ASP.Net anywhere.
- I’m not bound by Windows as the host operating system.
And if ASP.Net is your language of choice, you can also check out Deploy highly available ASP.Net applications on Oracle Cloud Infrastructure in the Oracle Architecture Center (here).
fn init --runtime node nodefn
which creates the files that you need to get started.
func.js func.yaml package.json
For C#, there is a different approach, the installation of the ASP.Net framework requires a few more things. The creating a serverless function tutorial for C# can be found (here) and to create the template project is a little different.
fn init --init-image daniel15/fn-dotnet-init --trigger http csharpfn
The main difference here is that there is a docker image that underpins the function that is used to both build the function and run it.
At the time of trying this out, it wasn’t smooth and it failed. That’s ok because it was easily fixed. At the time when this image was built, it was based upon ASP.Net 2.2. Since, then the base docker images for 2.2 are no longer available where 3.1 is the LTS version and 5.0 is the current version.
I’ve sinced forked the github project to (here) and updated the docker image to use ASP.Net 5.0. To run with this version:
0. Assumed Pre-Requisites
1. Clone this fdk-dotnet repository
This is the code that you will need to create the base image for the serverless function.
git clone https://github.com/jlowe000/fdk-dotnet
2. Build the base image
This will build the base image and will tag it.
cd fdk-dotnet/images/init docker build -t fdk-dotnet:5.0 .
3. Continue with the Tutorial
This is where you can continue with the FN tutorial (here) however there is a small change to the instructions. Instead of referring to the base image being daniel15/fn-dotnet-init, use the image tag that you created fdk-dotnet:5.0.
fn init --init-image fdk-dotnet:5.0 --trigger http csharpfn
Continuing with this process, you will see the Microsoft docker image being used. And you will run through to the end of the tutorial safely.
Through this, it’s opens up the world of serverless to many different use-cases that people can get into. If C# is something that you use, try this out and let me know what you come up with.
If you want to try this out yourself or work on your own application, sign-up (here) for the free Oracle Cloud Trial. I’d be interested to hear your experiences and learn from others as well. Leave a comment or contact me at email@example.com if you want to collaborate.