You can read environment variables from the 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 shows the method for reading the environment variable and printing the value of the environment variable.

var value = process.env.key
console.log(value)
import os
value = os.environ.get('key')
print(value)
System.out.println("value: "+ System.getenv("key"));
$value = getenv('key');
Console.WriteLine(Environment.GetEnvironmentVariable("key"));