What's New

IBM Cloud Functions Adds Support for .NET Core 2.2

Share this post:

What’s happening with IBM Cloud Functions and .NET Core?

I’m excited to announce that IBM Cloud Functions officially supports .NET Core 2.2 natively. Now, you can join the serverless revolution and start building cloud-native apps without worrying about scaling or infrastructure management by using Functions as a Service.

Ready to try it out?

  1. Create a C# project called `Example.`

    dotnet new classlib -n Example -lang "C#"
    cd Example/
  2. Install the Newtonsoft.Json NuGet package.

    dotnet add package Newtonsoft.Json -v 12.0.1
  3. Edit the Example/Class1.cs file.

    using System;
    using Newtonsoft.Json.Linq;namespace Example
    {
    public class Hello
    {
    public JObject Main(JObject args)
    {
    string name = "IBM Cloud";
    if (args.ContainsKey("name")) {
    name = args["name"].ToString();
    }
    JObject message = new JObject();
    message.Add("greeting", new JValue($"Hello, {name}!"));
    return (message);
    }
    }
    }
  4. Compile the code.

    dotnet publish -c Release -o out
  5. Create a .zip of the out directory.

    cd out
    zip -r -0 ../helloDotNet.zip *
    cd ..
  6. Create a web action with the IBM Cloud Functions CLI plugin by running the following command.

    ibmcloud fn action update helloDotNet helloDotNet.zip --main Example::Example.Hello::Main --kind dotnet:2.2 --web true
  7. Get the URL for the web action by running the following command.

    ibmcloud fn action get helloDotNet --url
  8. Open the URL in your browser.

How fast are .NET Core Functions?

Actions using the .NET Core runtime are very performant with an overhead similar to the fast Node.js runtime.

Here is a chart that compares the latency of a hello world Action in .NET vs. Node.js.

How do I learn more?

To see how easy it is to set up a project and compile your .NET Core Actions, check out the documentation.

Senior Technical Staff Member (STSM) - IBM Cloud Functions

More What's New stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading