Skip to content

Commit a0ed5ac

Browse files
committed
Update intro
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent a258344 commit a0ed5ac

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

_posts/2024-04-19-dotnet8-template.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,27 @@ author_staff_member: han
1313
hide_header_image: true
1414
---
1515

16-
We created a new template for C# and .NET 8.0. The template is based on the ASP.NET Core [Minimal API](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-8.0).
16+
We have created a new OpenFaaS template for C# and .NET 8.0 and it's based on the [Minimal API](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-8.0) of ASP.NET Core.
1717

18-
In the past we had an official csharp that used the original forking mode of the OpenFaaS watchdog, which created one process per request, and was less efficient than newer templates where one process would handle many requests concurrently. There were also a number of unofficial templates adopted by the community, which were not necessarily kept up to date, or something that we could support directly.
18+
In the past we provided a basic `csharp` template that used the original forking mode of the OpenFaaS watchdog, which created one process per request, and was less efficient than newer templates where one process would handle many requests concurrently.
19+
20+
There were also a number of unofficial templates adopted by the community, which were not necessarily kept up to date, or something that we could support directly.
1921

2022
The new template is called: `dotnet8-csharp` and has the following benefits:
2123

2224
- Adding NuGet packages to a function for additional dependencies.
2325
- Register services for dependency injection
24-
- Using ASP.NET Core middleware
26+
- Uses the latest ASP.NET Core middleware
27+
- Based upon the highly-performant Kestrel HTTP server
2528

2629
In the next section we will walk through an example that show you how to develop and deploy an OpenFaaS function with C# and the new template.
2730

31+
In function will read rows from a database table, and return them as JSON.
32+
33+
We'll then briefly discuss a few other features like dependency injection and how to use ASP.NET middlewares such as the static fileserver.
34+
35+
OpenFaaS templates provide a handler, some way to add dependencies, and a build system to create an OCI compatible image. But if you're already building your own images, you can deploy them to OpenFaaS if they provide a HTTP server. See also: [Build ASP.NET Core APIs with Kubernetes and OpenFaaS](https://www.openfaas.com/blog/asp-net-core/)
36+
2837
## Prerequisites
2938

3039
We won't go into detail on how to deploy OpenFaaS and assume you are already running OpenFaaS on Kubernetes or on a VM with [faasd](https://github.com/openfaas/faasd). Check out the [deployment guide](https://docs.openfaas.com/deployment/) for more information.
@@ -36,14 +45,14 @@ In this section we will walk through an example showing how to create a function
3645

3746
We will assume you are already running a Postgres database somewhere. You can use one of the many DBaaS services available, run a postgres with docker or use [arkade](https://github.com/alexellis/arkade) to quickly deploy a database in your cluster. If you are running faasd, the official guide [Serverless For Everyone Else](https://openfaas.gumroad.com/l/serverless-for-everyone-else) has a chapter that shows how to deploy PostgreSQL as an additional service.
3847

39-
To quickly deploy PostgreSQL in your Kubernetes cluster run `arkade install postgresql`. After the installation it will print out all the instructions to get the password and connect to the database.
48+
You could use a managed PostgreSQL service from AWS, GCP, DigitalOcean, etc, or deploy a development version of PostgreSQL into your Kubernetes cluster using `arkade install postgresql`. After the installation it will print out all the instructions to get the password and connect to the database.
4049

4150
We will create a table and insert some records that can be queried by our function:
4251

4352
```sql
4453
CREATE TABLE IF NOT EXISTS employee
4554
(
46-
id INT PRIMARY KEY NOT NULL,
55+
id INT PRIMARY KEY NOT NULL,
4756
name TEXT NOT NULL,
4857
email TEXT NOT NULL
4958
);
@@ -174,7 +183,7 @@ faas-cli up
174183

175184
Invoking the function should return a json response that looks like this:
176185

177-
```
186+
```bash
178187
$ curl -i $OPENFAAS_URL/function/employee-api/employees
179188

180189
HTTP/1.1 200 OK

0 commit comments

Comments
 (0)