Deploy a Function

Now that you have developed and tested your function locally, deploy it so that you can invoke it from your Salesforce org. The first time a Function is deployed, the upload may be 500 MB in size or more.

You deploy projects to your compute environment rather than individual Functions. For this guide we've created a DX project with a single Function.

Add Project to git

Before you deploy, commit your Functions code changes to a git repo. The deploy process uses changes tracked in git to know what to deploy. Since you just created this project, add the project to a new repo.

First cd to the root directory of your DX project. Then, use the following git commands:

Optionally, at this point you could also push your changes to, but this isn't required for deploying Functions.

Your project is now ready to deploy. If you make additional changes to your Function code, use git add and git commit to commit those changes to the repo before deploying again.

For more details on adding your repo to, see Create a repo.

Deploy Function to Compute Environment

To deploy your project's Function, use the following command with the scratch org alias we created earlier.

The deploy process may take several minutes.

To check the status of your deployed project, use sf env list.

For more details on deploying projects, see the Salesforce Functions Developer Guide.