How to Configure Functions

Functions are blocks of code that run on demand without the need to manage any infrastructure. Develop on your local machine, test your code from the command line (using doctl), then deploy to a production namespace or App Platform — no servers required. Learn more about functions.


If you have deployed a function through the DigitalOcean Control Panel, you can configure it using its Settings tab.

Note

Functions that have been deployed from the command line using doctl should be configured through their project.yml file instead. Any settings changed in the control panel could be overwritten by future command line deploys.

See the Project Configuration YAML File reference for more information on configuring settings using project.yml.

To get to a function’s Settings tab, first navigate to the function in the control panel: find the function that you’d like to update in the function list, then click its name to go to the function’s Source tab. Then, click the Settings tab:

The settings tab of an individual function, showing options for Runtime, Limits, Environment Variables, and Access & Security

From this tab you can configure the function’s runtime, resource limits, environmental variables, and its access and security settings. You can also destroy the function to permanently delete it.

Runtime Setting

A function’s runtime is the programming language environment that runs your code. To change the runtime, click the Edit text beside the runtime setting. Choose a new runtime from the dropdown menu, then press Save to save the selection.

Warning
If you change your runtime to a completely different language, your function’s code will be replaced with example code for the new language. If you change to a different version of the same language, your code will remain unchanged.

Resource Limits

The Limits section allows for editing the function’s timeout and memory limits. Click the Edit text to change these settings:

A screenshot of the interface for setting resource limits on a function, showing one text box for 'Timeout' and one for 'Memory'
  • Timeout: entered in milliseconds (ms), this setting determines the maximum length of time your function runs before it is terminated. This is useful for automatically ending function invocations that are taking longer than expected due to errors or connectivity issues. The maximum timeout is 15 minutes.
  • Memory: entered in megabytes (MB), this is the amount of memory resources available to your function. The maximum memory setting is currently 1024MB (1GB).

Environment Variables

The Environment Variables section shows how many environment variables are currently set. Click the Edit text to edit the variables.

The editing interface shows the current variables, a button for the Raw Editor, and a form where you can add key/value pairs one at a time.

To add an environment variable, fill out the Add Environment Variable form, then press Add. This screenshot shows the user adding an example_key=demo variable:

A screenshot of the interface for adding environment variables to a function, consisting of a 'Raw Editor' button and a form for entering key/value pairs.

After pressing Add the variable is added to the list of variables:

A screenshot of the environment variable interface showing one 'example_key' variable set.

From here, you must press Save to save the changes to your variables and exit out of the editing interface.

An alternate way of adding and editing environment variables is to use the raw editor. This can be useful for copying and pasting multiple variables at once. Click the Raw Editor button to open the editor:

A screenshot of the raw environment variable editing interface, which looks like a text editor with two lines, one for 'example_key' and one for 'second_key'.

You may add key=value pairs following standard .env file rules. Hit Save and the variables will be parsed and the list of variables will be updated. Press Save again to save the new set of variables and exit the editing interface.

Access & Security

This section allows you to control settings related to Web Functions and function authentication. It also shows example curl commands for invoking the current function.

Web Functions are functions that are accessible through normal HTTP methods such as GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS. These functions are expected to be synchronous, meaning they accept requests, do their work, and return a response as soon as possible (within the configured timeout).

Click the Edit text to configure the Web Functions Settings:

A screenshot of the Web Function options, including checkboxes for 'Web Function', 'Raw HTTP', and 'Secure Web Function'.

There are three checkboxes to configure:

  • Web Function: determines if the web function feature is enabled. If you disable web functions, you can still access your function through the authenticated REST API.
  • Raw HTTP: when enabled, the function receives requests as base64-encoded text, instead of a parsed JSON body.
  • Secure Web Function: by default, web functions can be invoked by anybody who knows the function URL. To require authentication, enable Secure Web Function. This prompts you to enter a secret token, which you will then need to provide in the x-require-whisk-auth header for each request.

Destroy Function

To permanently destroy your function, click Destroy. A confirmation form pops up. Enter the function name into the field and then press Destroy again to confirm.

You can read more about the Destroy feature in How to Destroy Functions