Manage Compute Environments

Create a Compute Environment for an Org

Before you can deploy a function or invoke a function from an org, you must create a compute environment. A compute environment in the Salesforce cloud represents a place where your deployed functions run. When you create a compute environment you specify an org that the compute environment is connected to. That org can then access and invoke functions deployed to that compute environment.

When developing a function, create compute environments associated with your sandbox or scratch orgs. When you're ready to deploy the function to production, create a compute environment associated with your production org and deploy your function to that compute environment.

To create a compute environment, use the sf env create compute command, specifying the org, and optionally an alias that you can use after the compute environment has been created:

sf env create compute -o MyOrgAlias -a MyComputeEnv

Creating compute environment for org ID 00D90060200AAPG... done!
New compute environment created with name MyComputeEnv-00D90060000AAPG-afg66b
Connecting environments... done!
Your compute environment with alias "MyComputeEnv" is ready.

List Compute Environments

To check which compute environments you've created, use the sf env list command:

sf env list
Current environments for project MyFunctionProject

Type: Compute Environment
ALIAS        PROJECT NAME      CONNECTED ORG ALIAS CONNECTED ORG ID   COMPUTE ENVIRONMENT NAME
MyComputeEnv MyFunctionProject MyScratchOrgAlias   00DS0000003dRFdTAM myfunct-00ds0000003drfdpam-786

Delete Compute Environments

If you no longer need a compute environment, or you wish to disconnect a connected org, use the sf env delete command with the compute environment alias to remove the compute environment:

sf env delete -e MyComputeEnv

Manage Function Environment Variables

Manage and set environment variables your function needs at runtime.