Manage Function Environment Variables
Use environment variables to represent values your function needs at runtime, such as securely storing credentials or configuration details. Environment variables are securely stored in the Salesforce Functions Compute Cloud, and can be accessed by your function code as system variables.
To manage environment variables, use the
sf env var CLI commands. These commands require specifying a Compute Environment where the environment variables are set or unset.
To set an environment variable in a compute environment, use
sf env var set:
Set multiple environment variables in a single command:
sf env var get or
sf env var list to inspect what environment variables are set to in a given compute environment:
To remove an environment variable from a compute environment, use the
sf env var unset command:
To test your function locally, use
sf run function start with local environment variables your function can access.
You can set additional
.env variables by adding the
Environment variables appear as standard system variables when your function runs. Use standard system variable APIs provided by your programming language to access environment variables.
For example, to access the
GITHUB_USERNAME in a Java Function, use