Kuno is a flexible framework for microservices that bridges core concepts with open-source components. This quick start will give you a better understanding of what is possible. At the end, you will have a good starting point for basic APIs. The sections that follow will continue to build upon this quick start.

Read: 2 minutes Code: 5 minutes

Create a Project

Create a new .NET Core console application named HelloWorldService in Visual Studio 2017.

Update the framework to use .NET 4.6.1 by right-clicking on the project in Solution Explorer and then clicking on “Edit HelloWorldService.csproj”.

The resulting project file should look like the following:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
</Project>

Install the Kuno.AspNetCore NuGet package. You can do this by running the following command in the Package Manager Console.

Install-Package Kuno.AspNetCore

Running this command will also install dependencies including the core Kuno NuGet package.

Create a Request, Function and Host

Create a class named HelloWorldRequest.

public class HelloWorldRequest
{
    public string Name { get; set;  }
}

Create a function named HelloWorld.

[EndPoint("greet")]
public class HelloWorld : Function<HelloWorldRequest, string>
{
    public override string Receive(HelloWorldRequest instance)
    {
        return "Hello " + instance.Name + "!";
    }
}

The last snippet does require you to resolve dependencies. Either use your favorite tool to automatically add them or add the following imports.

using Kuno;
using Kuno.AspNetCore;
using Kuno.Services;

Initialize a new Stack and call RunWebHost.

static void Main(string[] args)
{
    using (var stack = new KunoStack())
    {
        // This adds AspNetCore components to the stack and runs the Kestrel web host.
        stack.RunWebHost();
    }
}

Run the Application

Now that you’ve added the most basic components, you can start the application in debug more or skip debug mode. It should start up the console and run the Kestrel host.

Explore

In a web browser, navigate to http://localhost:5000/swagger.

  1. Expand the Hello World endpoint, click “Try it out”, and then “Execute”.
  2. After making some calls to your endpoint, try out the Get Requests and Get Responses endpoints.
  3. Check the console to see the output.

Next Steps

Now you’ve got the basics you can continue on to next steps. There you will update your API definition and endpoints with additional information.