Apache OpenWhisk Runtime .Net supports Apache OpenWhisk functions written in .Net languages

Clone this repo:
  1. a3f8d24 update github action versions (#80) by David Grove · 10 weeks ago master
  2. f0f4466 prep for 1.17 release (#79) by David Grove · 12 months ago 3.1@1.17.0 6.0@1.17.0
  3. 88de330 add GitHub Action badge; remove Travis scripts and configuration (#78) by David Grove · 1 year, 2 months ago
  4. 31902ce handle naming conventions for core subprojects (#77) by David Grove · 1 year, 2 months ago
  5. 54b09c5 update core OpenWhisk version (#76) by David Grove · 1 year, 2 months ago

Apache OpenWhisk runtimes for .NET

License Continuous Integration

Give it a try today

Create a C# project called Apache.OpenWhisk.Example.Dotnet:

dotnet new classlib -n Apache.OpenWhisk.Example.Dotnet -lang "C#"
cd Apache.OpenWhisk.Example.Dotnet

Install the Newtonsoft.Json NuGet package as follows:

dotnet add package Newtonsoft.Json -v 13.0.1

Now create a file called Hello.cs with the following content:

using System;
using Newtonsoft.Json.Linq;

namespace Apache.OpenWhisk.Example.Dotnet
{
    public class Hello
    {
        public JObject Main(JObject args)
        {
            string name = "stranger";
            if (args.ContainsKey("name")) {
                name = args["name"].ToString();
            }
            JObject message = new JObject();
            message.Add("greeting", new JValue($"Hello, {name}!"));
            return (message);
        }
    }
}

Publish the project as follows:

dotnet publish -c Release -o out

Zip the published files as follows:

cd out
zip -r -0 helloDotNet.zip *

Create the action

wsk action update helloDotNet helloDotNet.zip --main Apache.OpenWhisk.Example.Dotnet::Apache.OpenWhisk.Example.Dotnet.Hello::Main --kind dotnet:6.0

For the return result, not only support dictionary but also support array

So a very simple hello array function would be:

using System;
using Newtonsoft.Json.Linq;

namespace Apache.OpenWhisk.Tests.Dotnet
{
    public class HelloArray
    {
        public JArray Main(JObject args)
        {
            JArray jarray = new JArray();
            jarray.Add("a");
            jarray.Add("b");
            return (jarray);
        }
    }
}

And support array result for sequence action as well, the first action‘s array result can be used as next action’s input parameter.

So the function can be:

using System;
using Newtonsoft.Json.Linq;

namespace Apache.OpenWhisk.Tests.Dotnet
{
    public class HelloPassArrayParam
    {
        public JArray Main(JArray args)
        {
            return (args);
        }
    }
}

Changelogs

Quick Start Guides

License

Apache 2.0