You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/functions/create.md
+45-9Lines changed: 45 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Create a function
2
2
3
-
Install FaasNet template
3
+
Install FaasNet template. This utility can be used to generate Function project in C#.
4
4
5
5
```
6
6
dotnet new --install FaasNet.Templates
@@ -21,8 +21,11 @@ dotnet new faasnetfn -n Function
21
21
The following files will be created :
22
22
23
23
**Startup.cs* and *Program.cs*: the application entry point.
24
-
**HelloWorldConfiguration.cs*: configuration of the function.
25
-
**FunctionHandler.cs*: logic of the function.
24
+
**HelloWorldConfiguration.cs*: configuration properties of the function.
25
+
**FunctionHandler.cs*: contains the business logic. This class has one function which accepts one parameter and returns a JSON result. The input parameter has two distinct properties :
26
+
27
+
* Configuration: its value is coming from the gateway, it will be used to configure the behavior of the function for example : `ConnectionString` and `SQL Statement`.
28
+
* Input: value passed by caller.
26
29
27
30
In case the Visual Studio Support is needed, a solution can be created :
28
31
@@ -31,28 +34,61 @@ cd ..
31
34
dotnet new sln -n QuickStart
32
35
```
33
36
34
-
Add the Function project into the solution :
37
+
Add the Function project into the solution.
35
38
36
39
```
37
40
dotnet sln add ./src/Function/Function.csproj
38
41
```
39
42
40
43
# Deploy a function
41
44
42
-
Create the docker file. Replace the `DIRECTORY` variable by the project directory.
45
+
> [!WARNING]
46
+
> Before you start, Make sure your working environment is properly configured.
47
+
48
+
When the Function project is ready, it can be deployed to the Gateway API.
49
+
50
+
First of all, open a command prompt and execute the following command line to create a Docker file. The `DIRECTORY` variable must be replaced by the directory of the Function.csproj project.
43
51
44
52
```
45
53
FaasNet.CLI function -df <DIRECTORY>
46
54
```
47
55
48
-
Build the docker image. Replace the `DIRECTORY` variable by the project directory, replace the `NAME` variable by the name of your image.
56
+
Execute the following instruction to locally build the Docker image.
57
+
The `DIRECTORY` variable must be replaced by the directory of the Function.csproj project, and the `IMAGENAME` variable must be replaced by the name of the Docker image for example : localhost:5000/function.
58
+
59
+
```
60
+
FaasNet.CLI function -db <DIRECTORY> -t <IMAGENAME>
61
+
```
62
+
63
+
Execute the following command line to push the local Docker image into a registry. The `IMAGENAME` variable must be replaced by the name of the Docker Image.
64
+
65
+
```
66
+
FaasNet.CLI function -dp <IMAGENAME>
67
+
```
68
+
69
+
Finally, execute the latest command line to deploy the function into the Gateway API. Replace the `FUNCTIONNAME` variable by the name of your function and replace the `IMAGENAME` variable by the name of your Docker image.
70
+
71
+
```
72
+
FaasNet.CLI function deploy -name <FUNCTIONAME> -image <IMAGENAME>
73
+
```
74
+
75
+
# Execute a function
76
+
77
+
> [!WARNING]
78
+
> Before you start, Make sure you have a function deployed in the Gateway API.
79
+
80
+
Execute the following command to invoke a function. Replace the `FUNCTIONNAME` variable by the name of your function.
49
81
50
82
```
51
-
FaasNet.CLI function -db <DIRECTORY> -t <NAME>
83
+
FaasNet.CLI function invoke <FUNCTIONNAME> -input {} -configuration {'firstName':'coucou'}
52
84
```
53
85
54
-
Push the docker image into the Hub. Replace the `NAME` variable by the name of your image.
0 commit comments