Update content

How to create a function

Reviewed on 26 May 2021Published on 26 May 2021

This page shows you how to deploy your first Scaleway Elements Function. A function is a lightweight unit of logic, defining a procedure for changing one element into another. The function remains static, while the variables that pass through it can vary. The Scaleway Functions platform makes your function available, executes it on demand and manages resource allocation for you.

  1. Click Functions in the Compute section of the side menu. The Functions page displays.

  2. Click the Functions namespace you want to use to create your function.

  3. Click Create a Function. The Function creation wizard displays.

  4. Complete the following steps in the wizard:

    • Enter your function code.
      • From the first drop-down menu, choose to either use the inline code editor to edit your code directly from your browser in the box provided, or to upload a *.zip archive.
      • From the second drop-down menu, choose your desired runtime, e.g. node8, node10, node14, python2, python3, or golang.
      • From the third drop-down menu, set the Handler for your function
    • Choose a name for your function, and optionally a description. The name must only contain alphanumeric characters.
    • Choose the resources to be allocated to your function at runtime. These define the performance characteristics of your function.
    • Set your scaling preferences, or leave them at default values. The Scaleway platform autoscales the number of available instances of your function to match the incoming load, depending on the settings you define here.
    • Define any environment variables you want to inject into your function. For each environment variable, click +Add and enter the key/value pair.
    • Set the desired privacy policy for your function. This defines whether a function can be executed anonymously (public) or only via an authentication mechanism provided by Scaleway (private).
    • Optionally, use the advanced options to add triggers to your function deployment. Adding triggers enables the function to handle events coming from sources other than an HTTP endpoint, such as CRON (time-based jobs), MQTT queues and more.
    • Verify the estimated cost.
  5. Click Create a function to finish.

See Also