Deploy a Function
Now that you have developed and tested your function locally, it is time to deploy it so that you can invoke it from your Salesforce org. Note that the first time a Function is deployed, the upload may be 500MB in size or more, so ensure your network connection is working (you may need to disconnect from a VPN to improve network bandwidth).
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, you need to 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, you'll 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 github.com, but this isn't required for deploying Functions. For more details on adding your repo to github.com, see Create a repo.
Your project is now ready to deploy. If you make additional changes to your Function code, you'll want to use
git add and
git commit to commit those changes to the repo before deploying again.
Deploy Function to Compute Environment
To deploy your project's Functions use the following command with the scratch org alias we created earlier.
The deploy process may take several minutes.
You can check the status of your deployed projects using
For more details on deploying projects, see the Salesforce Functions Developer Guide.