Code examples for supported FaaS runtimes
This article introduces developers to the capabilities of FaaS for all supported runtimes: .NET, Go, Java, Node.js, and Python. For each runtime, we provide examples of three abstract functions of ascending levels of complexity:
- A basic function (“Hello world!”)
- A function with dependencies
- A function for accessing a data request/response
C#
Basic C# “hello world” function
C# function with dependencies
This function uses the YamlDotNet
dependencies.
To build this function, specify the dependencies in the .csproj format:
C# function accessing the data request
For all runtimes, you can find the request object in the event
map field. Each language has a unique type. For C#, it’s HttpRequest
from Microsoft.AspNetCore.Http
.
The dependencies should be structured as follows:
Go
Basic Go “hello world” function
Go function with dependencies
This function uses the yaml
dependencies.
Dependencies should be defined as follows:
Go function accessing request/response objects
The event extension includes request, response, and context objects. These can be accessed for improved precision in function management:
Java
Basic Java “hello world” function
Java function with dependencies
Dependencies should be defined as follows:
Java function accessing the request
Node.js
Basic Node.js “hello world” function
Node.js function with dependencies
The dependencies should be structured as follows:
Node.js function accessing object request/response
Python
Basic Python “hello world” function
Python function with dependencies
The dependencies should be structured as follows: