Create a Scratch Org

A scratch org is a source-driven and disposable deployment of Salesforce code and metadata. You'll use a scratch orgs to do your Salesforce Functions development and local testing.

Switch to your new DX project’s root directory:

Edit the config/project-scratch-def.json file to enable the "Functions" feature and save. We will use this configuration to create a new Scratch Org:

Use this updated scratch org definition file to create a new scratch org by running this command in your project's root directory:

  • -s set the created org as the default
  • -f definitionfile path to the scratch org definition file
  • -a set an alias for the created scratch org

See sfdx force:org:create --help for information on options.

See Scratch Orgs for more information on scratch orgs.

Create Salesforce Compute Environment for Scratch Org

After creating the scratch org, you need to create a Salesforce compute environment that is associated with the scratch org. This compute environment is where your Functions will get deployed to.

  • -o orgAlias Alias of the org the compute environment is connected to
  • -a alias Alias for the newly created compute environment