Environment variables can decouple function code from configurations to improve the flexibility and portability of the code. You can use environment variables in Function Compute to dynamically pass configuration information to function code. This prevents configuration information from being hard-coded in the function code. As a part of function configuration, environment variables are stored as key-value pairs. Different functions can contain different environment variables that are mutually independent.


After you configure environment variables, the environment variables are configured to the operating system environment when a function is executed. You can read the configured environment variables from the system environment variables.

When you create or update environment variables, Function Compute encrypts and stores the environment variables by using Advanced Encryption Standard (AES) 256. When you execute the function, the environment variables are automatically decrypted in reverse. This ensures data security.


  • Deploy a function on different platforms or services

    The configurations of the same function code may be different in the test environment and production environment. For example, you can use environment variables to select different Object Storage Service (OSS) buckets, databases, or tables. This way, you can deploy the same function to different platforms or environments without modifying the function code.

  • Configure a key

    You can use environment variables to configure security-sensitive authentication information, such as a username and a password for connecting to a database and your Alibaba Cloud AccessKey pair.

  • Configure system variables

    You can configure the PATH and HOME variables to system directories.


  • Character set rules
    • A key must start with a letter and can contain letters and digits.
    • A value must contain printable ASCII characters and cannot contain other characters such as Chinese characters.
  • Size limits

    The total size of environment variables cannot exceed 4 KB.

  • Reserved variables

    To prevent confusion, you cannot use the environment variables that Function Compute reserves. Reserved variables include FC_*, accessKeyID, accessKeySecret, securityToken, and topic.