C# Serverless on OCI

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.

fnproject.io supported languages – golang, Java, javascript, python, ruby and C#.

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).

The fnproject application lifecycle starts with creating the serverless function template project. With the languages that I gravitate to for those “get it done and done fast” projects – that being Javascript or Python, the syntax is:

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

I assume that you’ve installed fnproject.io (here) or have access to Oracle Cloud so you can deploy to Oracle Functions. Also, you have docker installed (here) so you can build the base image.

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.

Hello world

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 jason.lowe@oracle.com if you want to collaborate.


Author: Jason Lowe

I am passionate about how organisations adopt IT quickly and sustainably to achieve a specific and measurable outcome. This thinking is supported through lean IT practices in operational support and project delivery, and adopting these practices with Oracle technologies by creating sustainable platforms. I'm also interested different perspectives and drivers - from enterprise to start-ups, academia to commercial to public sector, cost-sensitive (risk) to value-driven (reward) - all of which influences decisions that organisations make. I have a passion for community and have been called "a connector" - meeting new people that are trying to solve valuable and hard problems and connecting them with others that can validate and help realise their full potential. I've supported different organisations like TADHack and Hacking Health as a global organiser. I'm is a persistent blogger on medium.com and redthunder.blog and on LinkedIn - https://www.linkedin.com/in/lowe-jason #CommunityMatters #ItTakesAVillage

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: