run Commands

Commands to run a function.

run function

Send a cloudevent to a function.

Examples for run function

Run a function:

1sf run function --url http://path/to/function

Run a function with a payload and a JSON response:

1sf run function --url http://path/to/function --payload '@file.json' --structured

Usage

sf run function
[-l FUNCTION-URL]
[-H HEADERS]
[-p PAYLOAD]
[-s]
[-o CONNECTED-ORG]

Flags

-l | --function-url FUNCTION-URL
Optional

URL of the function to run.

Type: option
-H | --headers HEADERS
Optional

Set headers.

Type: option
-p | --payload PAYLOAD
Optional

Set the payload of the cloudevent as a JSON object or a path to a file via @file.json.

Type: option
-s | --structured
Optional

Set the cloudevent to be emitted as a structured JSON cloudevent.

Type: boolean
-o | --connected-org CONNECTED-ORG
Optional

Username or alias for the target org; overrides default target org.

Type: option

run function start

Build and run a Salesforce Function.

Description for run function start

Run this command from the directory of your Salesforce Functions project.

This command will run the target function locally (on the same operating system as this CLI), just like the `local` subcommand.

Previously, this command ran functions in a container. Container mode is still supported via the `container` subcommand. Arguments relevant to container mode are still accepted, but are deprecated, ignored, and will be dropped in a future release.

Examples for run function start

Build a function and start the invoker

1sf run function start

Start the invoker with a specific language and port

1sf run function start --port 5000 --language javascript

Usage

sf run function start
[-p PORT]
[-b DEBUG-PORT]
[-l LANGUAGE]
[-v]

Flags

-p | --port PORT
Optional

Port for running the function.

Type: option
Default value: 8080
-b | --debug-port DEBUG-PORT
Optional

Port for remote debugging.

Type: option
Default value: 9229
-l | --language LANGUAGE
Optional

The language that the function runs in.

Type: option
Permissible values are: javascript, typescript, java, auto
Default value: auto
-v | --verbose
Optional

Output additional logs.

Type: boolean

run function start container

Build and run a Salesforce Function in a container.

Description for run function start container

Run this command from the directory of your Salesforce Functions project.

Examples for run function start container

Build and run a function:

1sf run function start container

Run a function on a specific port with additional logs:

1sf run function start container --port 5000 --verbose

Add environment variables and specify a network:

1sf run function start container --env KEY=VALUE --network host

Usage

sf run function start container
[-p PORT]
[-b DEBUG-PORT]
[--clear-cache]
[--no-pull]
[-e ENV]
[--network NETWORK]
[-v]

Flags

-p | --port PORT
Optional

Port for running the function.

Type: option
Default value: 8080
-b | --debug-port DEBUG-PORT
Optional

Port for remote debugging.

Type: option
Default value: 9229
--clear-cache
Optional

Clear associated cache before executing.

Type: boolean
--no-pull
Optional

Skip pulling builder image before use.

Type: boolean
-e | --env ENV
Optional

Set environment variables (provided during build and run).

Type: option
--network NETWORK
Optional

Connect and build containers to a network. This can be useful to build containers which require a local resource.

Type: option
-v | --verbose
Optional

Output additional logs.

Type: boolean

run function start local

Description for run function start local

Build and run a Salesforce Function locally.

Examples for run function start local

Build a function and start the invoker

1sf run function start local

Start the invoker with a specific language and port

1sf run function start local --port 5000 --language javascript

Usage

sf run function start local
[-p PORT]
[-b DEBUG-PORT]
[-l LANGUAGE]

Flags

-p | --port PORT
Optional

Port to bind the invoker to.

Type: option
Default value: 8080
-b | --debug-port DEBUG-PORT
Optional

Port to use for debbugging the function.

Type: option
Default value: 9229
-l | --language LANGUAGE
Optional

The language that the function runs in.

Type: option
Permissible values are: javascript, typescript, java, auto
Default value: auto