Deploy a Function

Now that you’ve developed and tested your function locally, deploy your project so you can invoke your function from your Salesforce org. The first time a Salesforce Functions project is deployed, the upload can be 500 MB or more.

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.

From the root directory of your project, use the following git commands:

1git init
2git add .
3git commit -m "Initial project commit after project creation"

At this point you can optionally push your changes to github.com, but it isn’t required for deploying a function.

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 github.com, 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.

1sf deploy functions -o MyOrgAlias

The deploy process can take several minutes.

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

1sf env list
2Salesforce Orgs
3============================================================================================================================================
4| Aliases Username                                         Org ID             Instance Url                        Auth Method Config
5| ─────── ──────────────────────────────────────────────── ────────────────── ─────────────────────────────────── ─────────── ──────────────
6|         functionsuser@salesforce-developers.com          00D3h000000Gr9mEAC https://na111.salesforce.com        web
7| DevHub  myuserfunctions@salesforce.com                   00D5e000002URZtEAO https://user-dev-ed.my.salesforce.… web
8| d16673… myuser1234@d16673dc-20210803-functions-trial.com 00D5e000003TQoSEAW https://d16673dc-20210803-function… web         target-dev-hub
9| Bob_De… bob@ding.dong                                    00DB0000000KfREMA0 https://fc2bfda2-20210913-function… web
10| Prod_O… alan@ding.dong                                   00DB0000000KfREMA0 https://fc2bfda2-20210913-function… web
11
12Scratch Orgs
13==========================================================================================================================================
14| Aliases Username                      Org ID             Instance Url                                                 Auth Method Config
15| ─────── ───────────────────────────── ────────────────── ──────────────────────────────────────────────────────────── ─────────── ──────
16|         test-15zzduduspjn@example.com 00D3D000000BJJLUA4 https://mycompany.scratch.my.salesforce.com                  web
17
18Compute Environments
19============================================================================================================
20| Alias         Project Name            Connected Org Alias Connected Org Id   Compute Environment Name
21| ───────────── ─────────────────────── ─────────────────── ────────────────── ─────────────────────────────
22| Prod_Env_Alan GA_Bug_Bash_Prod_Manual Prod_Org_Alan       00DB0000000KfREMA0 ga-bug-00db0000000kfrema0-203

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

Product Retirement Announcement

Salesforce Functions is no longer available for purchase or renewal. To preserve the capabilities that Salesforce Functions provided to your org, deploy an alternative solution before your existing order term ends. See Salesforce Functions Retirement for more information on migrating your functions. Contact your Salesforce Account Executive for more information on Heroku.