OVH Guide

OVH Functions

OVH Functions is a FaaS (Function as a Service) platform that allows you to focus only on code.

You write functions code as you're used to, and deploy them with a single command. It's as simple as that.

OVH Functions manages the execution environment and the scalability of your functions.

Quickstart

Install the latest ovh-functions CLI

Download ovh-functions cli:

Make it executable:

# Linux/MacOS
chmod u+x ovh-functions

Set the cli directory in your PATH, to be available directly by typing ovh-functions (or ovh-functions.exe on Windows):

# On Linux/MacOS
export PATH=/path/to/ovh-functions:$PATH
# On Windows
SET PATH=%PATH%;c:\path\to\ovh-functions

Write your first function

Create a directory, go inside and generate an example with the init command:

mkdir -p hello
cd hello
ovh-functions init nodejs

This is a Javascript example, but the platform supports several programming languages: Node.js, Python, Go, Perl and Bash. To generate an example in another supported language you can specify it in the init command, replacing nodejs in the previous command by: go, python-2.7, python-3.6, perl or bash.

By default a JavaScript hello function is written in the example.js file.

exports.hello = function(event, callback) {
  var name = event.data || "World";
  console.log("event", event);
  callback(null, "Hello " + name + " from OVH Functions!")
}

The function configuration is written in a functions.ymlfile to describe:

  • the function name: hello
  • the runtime: nodejs
  • the handler: example.hello composed of:
  • example: the nodejs module file name without the extension
  • hello: the exported function name
# functions.yml
functions:
  hello:
    runtime: nodejs
    handler: example.hello

Deploy and execute your function

First you'll need to log in:

ovh-functions login

To deploy or update your function on OVH Functions, execute the command below from the folder where you created it:

ovh-functions deploy

Then you can invoke your function using the HTTP URL given in response of the deploy command or using the command:

ovh-functions exec hello

You can send some data available in the event.data parameter by piping to stdin:

echo "toto" | ovh-functions exec hello

Go further

List all your functions:

ovh-functions list

Get details about a function:

ovh-functions describe hello

Delete a function:

ovh-functions delete hello

Get functions metrics:

ovh-functions metrics

Stream or print functions logs:

ovh-functions logs -f
ovh-functions logs -f hello
ovh-functions logs
ovh-functions logs hello
ovh-functions logs -n 10
ovh-functions logs hello -n 10

Next: Read the documentation.

Then: Checkout some examples of function code.