Development and Application Lifecycle Workflow

As you develop a Function, you'll need to integrate your Function code into your development and application lifecycle workflow. This can include tasks like:

  • Collaborating on Function development with other developers on your team.
  • Adding Functions to your application lifecycle management process to ensure Functions are properly verified in a sandbox environment before being deployed to production.
  • Automating parts of your workflows, such as using automated testing and deployment of Functions.

Because Functions do not get deployed directly to your org, you need to use additional DX tools and commands to integrate Functions in your workflow.

Maintain and Share Function Source Code

Because Function code isn't deployed or saved to your org, you'll need to save your Function project in a source code control system. You can use git repos on github.com to save your Function code, along with the rest of your DX project. Once your Functions project is in github, you can use git branches, merges, and pull requests to track and safely merge development changes across your team.

To add an existing Functions project to github.com, see Add Project to github and the Add a Salesforce DX Project to Source Control Trailhead project.

When making Functions project changes, always start by creating a branch in your git repo. Work in this branch as you make changes to your Functions code, or org-side changes like permission set changes. Once you're ready to test in a scratch or sandbox org, be sure to commit first. Once you've verified your changes, you push merge your project commit, create a pull request for review, and merge your reviewed changes back to your repo.

Functions and Application Lifecycle Management

To integrate your Functions development and deployment in your application lifecycle management (ALM) process, you'll need to:

  1. Plan your Functions development. Understand what compute work your Function will be doing, what permissions your Function will need, and where a user will be invoking your Function from. Determine what language-specific packages beyond the Salesforce SDKs your Function might need. Understand which development, test, and integration orgs you'll need to create.
  2. Develop your Function. Develop and debug Functions locally using VS Code. Use git and github to track Functions project changes and coordinate changes across your development team. Develop your Apex code and any org-side changes needed to invoke the Function.
  3. Test your Function in a development org. Test your Function locally and then deploy and test in your development (scratch or sandbox) orgs. Use scratch orgs to test just your changes, or use development sandbox orgs to coordinate testing with others on your team.
  4. Deploy your Function to your integration sandbox orgs. Create compute environments based on your preferred set of sandbox orgs used for testing.
  5. Test your Function in your integration sandbox orgs.
  6. Release (deploy) your Function to your production org.

Here's a simplified example walkthrough of some of the above steps for a developer on a team developing Functions. This walkthrough assumes that the development team already has a DevHub org with Functions enabled, and each team member has the appropriate DX tools installed.

  1. For initial planning, the team determines that a new development sandbox and integration sandbox will be needed, so the developer creates these, either via the Salesforce UI, or via CLI commands like the following:
  1. The developer logs into the Dev Hub and dev and integration sandbox orgs. The developer also authenticates the Salesforce CLI to Salesforce Functions:

The developer creates a new project and commits it to git for everyone to work on:

Now, the developer can create a branch and develop Function code, Apex code, etc:

At this point the developer can also run the Functions locally using a scratch org.

  1. The developer has done some local testing using scratch orgs, and now wants to test in the development sandbox. They need to first ensure they've done a git commit for their project:

Next they need to create a compute environment for their developer sandbox. This only needs to be done once, and other developers on the team can deploy to the same compute environment:

The developer can then deploy the Functions project to the compute environment connected to the development sandbox for testing:

And finally the developer pushes whatever org-side changes, such as Apex classes, to the development sandbox directly:

At this point the developer can test the Functions and org-side changes in the development sandbox.

  1. Once testing has been completed, the developer wants to deploy and test in the integration sandbox. First, the developer pushes his git branch to github:

The developer uses the github web UI to create a pull request and get a review from someone on the team before merging into the integration branch. Once the changes are merged, the developer pulls the integration branch to make sure he has all the latest changes for that branch before he deploys:

Next the developer creates a compute environment for the integration sandbox. Again, this needs to be done once:

The developer is ready to deploy his Functions to the integration sandbox compute environment, and any org changes to the integration sandbox:

The developer can now test and validate the Functions and org-side changes in the integration sandbox.