You can use code to read system environment variables and configure the environment variables to the runtime environment of a function to run the function. This topic describes the sample code for using environment variables in different runtime environments.

Sample code

Assume that the environment variable {"key":"val"} is configured. The following code provides an example on how to read the environment variable and print the value of the environment variable:

var value = process.env.key
import os
value = os.environ.get('key')
System.out.println("value: "+ System.getenv("key"));
$value = getenv('key');