Jump toUpdate content

Quickstart

Reviewed on 26 May 2021Published on 26 May 2021

The Scaleway Elements Functions platform makes your functions available, executes them on demand and manages resource allocation for you. 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. We show you how to create a Functions namespace, create your function, and delete when no longer needed.

Requirements:

How to create a Functions namespace

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

  2. Click Create a namespace. The Functions namespace creation wizard displays.

  3. Complete the following steps in the wizard:

    • Enter a name and optionally a description for your namespace. The name must only contain alphanumeric characters.
    • Choose a region, which is the geographical location in which your namespace will be deployed.
    • Enter any environment Variables required for your namespace. Environment variables configured in a namespace will be available in all functions/apps within the same namespace. For each environment variable, click +Add and ender the key/value pair.
    • Verify the estimated Cost.
  4. Click Create a namespace to finish.

Your namespace is now created and you are taken to its Functions tab.

How to create a function

  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.

How to delete a function

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

  2. Click the relevant Functions namespace.

  3. Click the «See more Icon» icon next to the function you want to delete, and select Delete from the dropdown menu.

  4. Type DELETE in the pop-up that asks you to confirm the action, then click Delete this function.

Tip:

You can also delete a function from the Function settings tab.