Skip to content

Commit

Permalink
Ticket ## : Update Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Oct 13, 2021
1 parent 22d0e97 commit 33a5fad
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 100 deletions.
2 changes: 1 addition & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"resource": [
{
"files": [
"images/**",
"documentation/**.png",
"charts/**"
]
}
Expand Down
94 changes: 94 additions & 0 deletions docs/documentation/functions/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Create a function

Install FaasNet template. This utility can be used to generate Function project in C#.

```
dotnet new --install FaasNet.Templates
```

Create a Function project

```
mkdir QuickStart
cd QuickStart
mkdir src
cd src
dotnet new faasnetfn -n Function
```

The following files will be created :

* *Startup.cs* and *Program.cs*: the application entry point.
* *HelloWorldConfiguration.cs*: configuration properties of the function.
* *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 :

* 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`.
* Input: value passed by caller.

In case the Visual Studio Support is needed, a solution can be created :

```
cd ..
dotnet new sln -n QuickStart
```

Add the Function project into the solution.

```
dotnet sln add ./src/Function/Function.csproj
```

# Deploy a function

> [!WARNING]
> Before you start, Make sure your working environment is properly configured.
When the Function project is ready, it can be deployed to the Gateway API.

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.

```
FaasNet.CLI function -df <DIRECTORY>
```

Execute the following instruction to locally build the Docker image.
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.

```
FaasNet.CLI function -db <DIRECTORY> -t <IMAGENAME>
```

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.

```
FaasNet.CLI function -dp <IMAGENAME>
```

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.

```
FaasNet.CLI function deploy -name <FUNCTIONAME> -image <IMAGENAME>
```

# Execute a function

> [!WARNING]
> Before you start, Make sure you have a function deployed in the Gateway API.
Execute the following command to invoke a function. Replace the `FUNCTIONNAME` variable by the name of your function.

```
FaasNet.CLI function invoke <FUNCTIONNAME> -input {} -configuration {'firstName':'coucou'}
```

The following message is displayed

```
{
"content": {
"message": "Hello 'coucou'"
}
}
```
31 changes: 0 additions & 31 deletions docs/documentation/functions/manage.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/documentation/gettingstarted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ kubectl apply -f https://raw.githubusercontent.com/simpleidserver/FaasNet/master
kubectl apply -f https://raw.githubusercontent.com/simpleidserver/FaasNet/master/kubernetes/mssql-internal-svc.yml --namespace=faas
```

Authenticate to the SQLServer database `127.0.0.1, 30002` with the following credentials :
Authenticate to the SQLServer database `127.0.0.1, 30010` with the following credentials :

| Parameter | Value |
| --------- | ------------ |
Expand Down
Binary file added docs/documentation/portal/images/manage1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/portal/images/manage2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/portal/images/manage3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/portal/images/manage4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/documentation/portal/images/manage5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 0 additions & 63 deletions docs/documentation/portal/index.md

This file was deleted.

66 changes: 66 additions & 0 deletions docs/documentation/portal/manage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Manage Functions

> [!WARNING]
> Make sure your working environment is [properly configured](/documentation/gettingstarted/index.html).
A Portal is available at the following [address](http://localhost:30003). It can be used by developers to manage functions.
The following chapters describe how functions can easily be managed.

# Publish a function

> [!WARNING]
> Before publishing a function, it should be available in an online store for example DockerHub. For more information please refer to this [chapter](/documentation/functions/create.html#deploy-a-function).
In the website, click on the `Add a function` button and fill in the form with the following information and click on `Create`.

* **Name** : This parameter is used to uniquely identify a function for example `test`.
* **Image**: Name of the Docker image for example : `simpleidserver/faastransform:0.0.3`.

![Publish function](images/manage1.png)

The function will be published and displayed in the table.

![Published functions](images/manage2.png)

# Unpublish a function

Navigate to the function and click on the `Delete` button present in the `Information` tab.

The function will be unpublished and removed from the table.

![Unpublish function](images/manage3.png)

# Invoke a function

Navigate to the function and click on the `Invoke` tab.

There are two types of parameter :

* **Configuration parameters** : The content is similar to what can be found in configuration files (web.conf or app.conf) for example : mapping rules between Input and Output fields or ConnectionString.
* **Input parameters** : Input parameters directly passed to the function.

If `faastransform` is published, it can be invoked like this :

* **Output parameters** : Add a new parameter and set the first field value to `firstname`, and specify `FIRSTNAME` in the second field.
* **Input parameter** : Specify the following JSON content.

```
{ "firstname" : "sid" }
```

Finally click on the `Launch` button. The JSON object above will be transformed into a new object which looks like to something like this :

```
{ "FIRSTNAME": "sid" }
```

![Invoke function](images/manage4.png)


# Monitor a function

Navigate to the function and click on the `Monitoring` tab.

There are several panels displayed in the UI. Each of them enable developers to follow the performance of the published function for examples : CPU Usage, Memory Usage or Number of request.

![Monitoring function](images/manage5.png)
2 changes: 1 addition & 1 deletion docs/documentation/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
- name: Portal
items:
- name: Manage functions
href: functions/manage.md
href: portal/manage.md
4 changes: 2 additions & 2 deletions faasnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ apis:
flows: []
functions:
- name: getsql
image: simpleidserver/faasgetsql:0.0.1
image: simpleidserver/faasgetsql:0.0.3
- name: transform
image: simpleidserver/faastransform:0.0.1
image: simpleidserver/faastransform:0.0.3
2 changes: 1 addition & 1 deletion kubernetes/mssql-external-svc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ spec:
- port: 1433
protocol: TCP
targetPort: 1433
nodePort: 30002
nodePort: 30010

0 comments on commit 33a5fad

Please sign in to comment.