IBM Cloud Docs
Cloud Functions CLI

Cloud Functions CLI

IBM Cloud® Functions is deprecated. Existing Functions entities such as actions, triggers, or sequences will continue to run, but as of 28 December 2023, you can’t create new Functions entities. Existing Functions entities are supported until October 2024. Any Functions entities that still exist on that date will be deleted. For more information, see Deprecation overview.

Run these commands to manage the entities that make up your functions.

Action commands

Create, invoke, list, and delete actions.

To see CLI help for the action command, run ibmcloud fn action.

ibmcloud fn action create

Create an action.

ibmcloud fn action create ACTION_NAME APP_FILE [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--copy] [--docker DOCKER_HUB_USERNAME/IMAGE_NAME] [--kind LANGUAGE] [--logsize LIMIT] [--main ENTRY_METHOD_NAME] [--memory MEMORY_LIMIT] [--native] [--param KEY VALUE] [--param-file FILE] [--sequence ACTION_NAME, ACTION_NAME] [--timeout LIMIT] [--web yes|true|raw|no|false] [--web-secure SECRET]

Command options

--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
ACTION_NAME
The name of the action. To include the action in a package, enter the name in the format PACKAGE_NAME/ACTION_NAME. This value is required.
APP_FILE
The path to the app file or package to run as an action. This option is required.
--copy
Treat the action as the name of an existing action.
--docker DOCKER_HUB_USERNAME/IMAGE_NAME
The Docker Hub user name and the name of the Docker image in Docker Hub to run the action. This option is required for creating actions from Docker images.
--kind LANGUAGE
The runtime for your app. This value is optional. If no VALUE is specified, the default version for the detected runtime is used. For possible values for the --kind option, see Runtimes.
--logsize LIMIT, -l LIMIT
The maximum log size in MB for the action. The default value is 10 MB.
--main ENTRY_METHOD_NAME
If the action's entry method is not main, specify the custom name. This option is required when the entry method is not main. For some runtimes, such as Java, the name must be the fully qualified method.
--memory MEMORY_LIMIT
The maximum memory limit in MB for your action. The default is 256 MB.
--native
You can use the --native argument as shorthand for --docker openwhisk/dockerskeleton. By using this argument, you can create and deploy an executable that runs inside the standard Docker action SDK. When you create a Docker image, an executable is created inside the container at /action/exec. Copy the /action/exec file to your local file system and compress it into exec.zip. Create a Docker action that receives the executable as initialization data. The --native argument replaces the --docker openwhisk/dockerskeleton argument.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--sequence ACTION_NAME, ACTION_NAME
Create an action sequence and include the names of the related actions. Separate the ACTION_NAMEs by commas.
--timeout LIMIT, -t LIMIT
The timeout LIMIT in milliseconds. The default value is 60000 milliseconds. When the timeout is reached, the action is terminated.
--web yes|true|raw|no|false
Treat the action as a web action, a raw HTTP web action, or as a standard action. Specify yes or true for a web action, raw for a raw HTTP web action, or no or false for a standard action. To secure your web action, also include the --web-secure option.
--web-secure SECRET
Secure the web action. The VALUE for SECRET can be true, false, or any string. This option can be used only with the --web option.

Example

ibmcloud fn action create hello folder/hello_world.js

Output

ok: created hello

ibmcloud fn action delete

You can clean up your namespace by deleting actions that you do not want to use any longer.

ibmcloud fn action delete ACTION_NAME

Example

ibmcloud fn action delete helloworld

Output

ok: deleted hello

ibmcloud fn action get

Get metadata that describes a specific action.

ibmcloud fn action get ACTION_NAME [--save] [--save-as FILENAME] [--summary] [--url]

Command options

ACTION_NAME
The name of an action. This value is required.
--save
You can get and locally save the code that is associated with an existing action, except for sequences and Docker actions. The FILENAME corresponds with an existing action name in the current working directory and the file extension corresponds to the action kind. For example, for action code that is an archive file, an extension of .zip is used. This value is optional.
--save-as FILENAME
Save the code for actions in a custom-named file by providing a file path, FILENAME, and extension. This value is optional.
--summary
Get a summary of the action details. Parameters with the prefix "*" are bound; parameters with the prefix "**" are bound and finalized. This value is optional.
--url
Get the URL only for the action. This value is optional.

Example

ibmcloud fn action get hello

Output

ok: got action hello
{
    "namespace": "<namespace_ID>",
    "name": "hello",
    "version": "0.0.1",
    "exec": {
        "kind": "nodejs:10",
        "binary": false
    },
    "annotations": [
        {
            "KEY": "exec",
            "VALUE": "nodejs:10"
        }
    ],
    "LIMIT s": {
        "timeout": 60000,
        "memory": 256,
        "logs": 10
    },
    "publish": false
}

ibmcloud fn action invoke

Run an action to test it.

ibmcloud fn action invoke ACTION_NAME [--blocking] [--param KEY VALUE] [--param-file FILE] [--result]

Command options

ACTION_NAME
The name of the action. This value is required.
--blocking, -b
Blocking invocations use a request and response style to wait for the activation result to be available. The wait period is the lesser of 60 seconds or the action's time LIMIT VALUE. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--result, -r
The result of the app code is displayed as the output of the command. If this option is not specified, the activation ID is displayed. The invocation is blocking when this option is specified. This value is optional.

Example

ibmcloud fn action invoke hello --blocking

ibmcloud fn action list

List all the actions that you created or a specific number of actions.

ibmcloud fn action list ACTION_NAME [--limit NUMBER_OF_ACTIONS] [--name-sort] [--skip NUMBER_OF_ACTIONS]

Command options

ACTION_NAME
The name of a package of actions. This value is optional. If not specified, all actions are listed.
--limit NUMBER_OF_ACTIONS, -l NUMBER_OF_ACTIONS
List a specified number of actions. The default is 30 actions.
--name-sort, -n
Sort the list of returned actions by name, otherwise the list is sorted by creation date.
--skip NUMBER_OF_ACTIONS, -s NUMBER_OF_ACTIONS
Exclude a specified number of the most recently created actions from the result.

Example

ibmcloud fn action list

ibmcloud fn action update

Update an action or the app within an action.

When you update parameters for a package or action, you must specify all previously created parameters. Otherwise, the previously created parameters are removed. For packages, any services that were bound to the package are also removed, so after you update other parameters you must bind services to your package again.

ibmcloud fn action update ACTION_NAME APP_FILE [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--copy] [--docker DOCKER_HUB_USERNAME/IMAGE_NAME] [--kind LANGUAGE] [--logsize LIMIT] [--main ENTRY_METHOD_NAME] [--memory MEMORY_LIMIT] [--native] [--param KEY VALUE] [--param-file FILE] [--sequence ACTION_NAME, ACTION_NAME] [--timeout LIMIT] [--web yes|true|raw|no|false] [--web-secure SECRET]

Command options

--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
ACTION_NAME
The name of the action. To include the action in a package, enter the name in the format PACKAGE_NAME/ACTION_NAME. This value is required.
APP_FILE
The path to the app file or package to run as an action. This option is required when you want to update your app within the action.
--copy
Treat the action as the name of an existing action.
--docker DOCKER_HUB_USERNAME/IMAGE_NAME
The Docker Hub user name and the name of the Docker image in Docker Hub to run the action. This option is required for creating actions from Docker images.
--kind LANGUAGE
The runtime for your app. This value is optional. If no VALUE is specified, the default version for the detected runtime is used. For possible values for the --kind option, see Runtimes.
--logsize LIMIT, -l LIMIT
The maximum log size in MB for the action. The default value is 10 MB.
--main ENTRY_METHOD_NAME
If the action's entry method is not main, specify the custom name. This option is required when the entry method is not main. For some runtimes, such as Java, the name must be the fully qualified method.
--memory MEMORY_LIMIT
The maximum memory limit in MB for your action. The default is 256 MB.
--native
You can use the --native argument as shorthand for --docker openwhisk/dockerskeleton. By using this argument, you can create and deploy an executable that runs inside the standard Docker action SDK. When you create a Docker image, an executable is created inside the container at /action/exec. Copy the /action/exec file to your local file system and compress it into exec.zip. Create a Docker action that receives the executable as initialization data. The --native argument replaces the --docker openwhisk/dockerskeleton argument.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameters KEYS and VALUES. This value is optional.
--sequence ACTION_NAME, ACTION_NAME
Create an action sequence by specifying the name of related actions.
--timeout LIMIT, -t LIMIT
The timeout limit in milliseconds. The default value is 60000 milliseconds. When the timeout is reached, the action is terminated.
--web yes|true|raw|no|false
Treat the action as a web action, a raw HTTP web action, or as a standard action. Specify yes or true for a web action, raw for a raw HTTP web action, or no or false for a standard action. To secure your web action, also include the --web-secure option.
--web-secure SECRET
Secure the web action. The VALUE for SECRET can be true, false, or any string. This option can be used only with the --web option.

Example

ibmcloud fn action update hello folder/hello_world.js

Activation commands

Get metadata, list IDs, find logs, and list results for specific activations.

To see CLI help for the activation command, run ibmcloud fn activation.

ibmcloud fn activation get

Get metadata that describes a specific activation.

ibmcloud fn activation get [ACTIVATION_ID] [FIELD_FILTER] [--last] [--summary]

Command options

ACTIVATION_ID
The ID for a specific activation. Use ibmcloud fn activation list to retrieve a list of available IDs. This value is required, unless the --last or -l option is specified..
FIELD_FILTER
A field in the metadata to display information from. For example, to display the logs field, run ibmcloud fn activation get ACTIVATION_ID logs. This value is optional.
--last, -l
Display the metadata for the most recent activation. This value is optional.
--summary, -s
Display the result response only from the activation details. This value is optional.

Example

ibmcloud fn activation get 8694a4501be6486a94a4501be6886a1e --summary

ibmcloud fn activation list

List all the activation IDs for all the actions in a package.

ibmcloud fn activation list [--full] [--limit NUMBER_OF_ACTIVATIONS] [--since UNIX_EPOCH_TIME] [--skip NUMBER_OF_ACTIVATIONS] [--upto UNIX_EPOCH_TIME]

Command options

--full, -f
Display the full activation description.
--limit NUMBER_OF_ACTIVATIONS, -l NUMBER_OF_ACTIVATIONS
List a specified number of activations. The default is 30 activations and the maximum is 200 activations.
--since UNIX_EPOCH_TIME
List activations that were created since the date specified. Duration is measured in milliseconds since 01 January 1970. Example: 1560371263 is 12 June 2019 08:27:43 UTC.
--skip NUMBER_OF_ACTIVATIONS, -s NUMBER_OF_ACTIVATIONS
Exclude a specified number of the most recent activations from the result.
--upto UNIX_EPOCH_TIME
List activations that were created before the date specified. Duration is measured in milliseconds since 01 January 1970. Example: 1560371263 is 12 June 2019 08:27:43 UTC.

Example

ibmcloud fn activation list

Output

activations
44794bd6aab74415b4e42a308d880e5b         hello
6bf1f670ee614a7eb5af3c9fde813043         hello

ibmcloud fn activation logs

Get logs for a specific activation.

ibmcloud fn activation logs [ACTIVATION_ID] [--last] [--strip]

Command options

ACTIVATION_ID
The ID for a specific activation. Use ibmcloud fn activation list to retrieve a list of available IDs. This value is required, unless the --last or -l option is specified.
--last, -l
Display the logs for the most recent activation. This value is optional.
--strip, -r
Display the log message only; exclude the timestamp and stream information. This value is optional.

Example

ibmcloud fn activation logs 8694a4501be6486a94a4501be6886a1e --summary

ibmcloud fn activation poll

View a streaming, live list of activations for an action or a namespace. You can press CTRL+C to exit the polling.

ibmcloud fn activation poll [NAMESPACE] [ACTION_NAME] [--exit SECONDS] [--since-days DAYS] [-since-hours HOURS] [--since-minutes MINUTES] [--since-seconds SECONDS]

Command options

/NAMESPACE
A namespace name or ID. Poll activations for a namespace, an action, or a space. This value is optional. If a namespace or action is not specified, the space is polled.
ACTION_NAME
An action name. Poll activations for a namespace, an action, or a space. This value is optional. If a namespace or action is not specified, the space is polled.
--exit SECONDS, -e SECONDS
Poll activations for a specified number of seconds and then exit. This value is optional.
--since-days DAYS
Start polling for activations a specified number of days ago. This value is optional.
--since-hours HOURS
Start polling for activations a specified number of hours ago. This value is optional.
--since-minutes MINUTES
Start polling for activations a specified number of minutes ago. This value is optional.
--since-seconds SECONDS
Start polling for activations a specified number of seconds ago. This value is optional.

Example

ibmcloud fn activation poll

ibmcloud fn activation result

Get the result from a specific activation.

ibmcloud fn activation result [ACTIVATION_ID] [--last] [--strip]

Command options

ACTIVATION_ID
The ID for a specific activation. Use ibmcloud fn activation list to retrieve a list of available IDs. This value is required, unless the --last or -l option is specified.
--last, -l
Display the result for the most recent activation. This value is optional.

Example

ibmcloud fn activation result 8694a4501be6486a94a4501be6886a1e

Deployment commands

Use deployment commands to deploy and undeploy packages, actions, triggers, and rules.

ibmcloud fn deploy

Use a manifest file to deploy a collection of packages, actions, triggers, and rules.

To see CLI help for the deploy command, run ibmcloud fn deploy.

ibmcloud fn deploy [--apihost HOST] [--auth KEY] [--config FILE][--deployment FILE] [--manifest FILE] [--namespace NAMESPACE][--param KEY VALUE] [--param-file FILE] [--preview][--project PATH] [--strict] [--verbose]

Command options

--apihost HOST
The wsk API host. This value is optional.
--auth KEY, -u KEY
The wsk authorization KEY. This value is optional.
--config FILE
The configuration file. The default is $HOME/.wskprops.
--deployment FILE
The path to the deployment file.
--manifest FILE, -m FILE
The path to the manifest file. This value is required if the manifest.yaml is not in the current directory.
--namespace NAMESPACE, -n NAMESPACE
The name or ID for a namespace.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--preview
Display the deployment plan before you deploy.
--project PATH
The path to the serverless project. The default is . (current directory).
--strict
Allow a user-defined runtime version.
--verbose, -v
View verbose output.

Example

ibmcloud fn deploy --manifest folder/manifest.yaml

ibmcloud fn undeploy

Use a manifest file to undeploy a collection of packages, actions, triggers, and rules.

To see CLI help for the undeploy command, run ibmcloud fn undeploy.

ibmcloud fn undeploy [--apihost HOST] [--auth KEY] [--config FILE] [--deployment FILE] [--manifest FILE] [--namespace NAMESPACE] [--param KEY VALUE] [--param-file FILE] [--preview] [--project PATH] [--strict] [--verbose]

Command options

--apihost HOST
The wsk API host. This value is optional.
--auth KEY, -u KEY
The wsk authorization KEY. This value is optional.
--config FILE
The configuration file. The default is $HOME/.wskprops.
--deployment FILE
The path to the deployment file.
--manifest FILE, -m FILE
The path to the manifest file. This value is required if the manifest.yaml is not in the current directory.
--namespace NAMESPACE, -n NAMESPACE
The name or ID for a namespace.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--preview
Display the result of the command without running the command.
--project PATH
The path to the serverless project. The default is . (current directory).
--strict
Allow a user-defined runtime version.
--verbose, -v
View verbose output.

Example

ibmcloud fn undeploy --manifest folder/manifest.yaml

List command

Use the list command to view packages, actions, triggers, and rules in the namespace.

ibmcloud fn list

View a grouped list of the packages, actions, triggers, and rules in the namespace.

ibmcloud fn list [--name-sort]

Command options

--name-sort, -n
Sort each group of returned entities by name, otherwise each group is sorted by creation date.

Example

ibmcloud fn list

Namespace commands

Create, update, delete, and find information about your namespace.

To learn how to target your Cloud Functions namespace, see Targeting namespaces.

To see CLI help for the namespace command, run ibmcloud fn namespace.

ibmcloud fn namespace create

Create an IAM namespace.

ibmcloud fn namespace create NAMESPACE [--description DESCRIPTION] 

Command options

NAMESPACE
The name for a namespace. Do not include hyphens (-) in the name. This value is required.
--description DESCRIPTION, -n DESCRIPTION
Write your own unique description to help you identify the namespace. If your description is more than one word, include quotation marks (") around your description. This value is optional.

Example

ibmcloud fn namespace create HBCTeamProd --description "HBC Team Prod Environment. See Beth for information about this namespace."

ibmcloud fn namespace delete

Delete an IAM namespace.

ibmcloud fn namespace delete NAMESPACE

Example

ibmcloud fn namespace delete mynamespace

ibmcloud fn namespace get

Get the entities for or the metadata information from a Cloud Foundry or IAM namespace.

ibmcloud fn namespace get NAMESPACE [--auth KEY] [--name-sort] [--properties] 

Command options

NAMESPACE
The name or ID for a namespace. This value is required.
--auth KEY, -u KEY
The wsk authorization KEY. This value is optional.
--name-sort, -n
Sort the list of returned namespaces by name, otherwise the list is sorted by creation date. This value is optional.
--properties
Display the namespace properties instead of the entities contained within it. This value is optional.

Example

ibmcloud fn namespace get user@domain.com_dev --properties

Output

Name: user@domain.com_dev
Description: This is a description of my namespace.
Resource Plan Id: functions-base-plan
Location: us-south
ID: 58c2e718-8c60-48bc-96de-cf9373fe6709

ibmcloud fn namespace list

List the available Cloud Foundry and IAM namespaces.

ibmcloud fn namespace list [--auth KEY] [--cf] [--iam] [--limit NUMBER_OF_NAMESPACES] [--name-sort] [--skip NUMBER_OF_NAMESPACES] 

Command options

--auth KEY, -u KEY
The wsk authorization KEY. This value is optional.
--cf
Display the Cloud Foundry namespaces only. IAM namespaces are not displayed. This value is optional.
--iam
Display the IAM namespaces only. Cloud Foundry namespaces are not displayed. This value is optional.
--limit NUMBER_OF_``NAMESPACE``S, -l NUMBER_OF_``NAMESPACE``S
List a specified number of namespaces. The default is 30 namespaces. This value is optional.
--name-sort, -n
Sort the list of returned namespaces by name, otherwise the list is sorted by creation date. This value is optional.
--skip NUMBER_OF_NAMESPACES, -s NUMBER_OF_``NAMESPACE``S
Exclude a specified number of the most recently created namespaces from the result. This value is optional.

Example

ibmcloud fn namespace list

ibmcloud fn namespace target

Target an available IAM or Cloud Foundry namespace.

ibmcloud fn namespace target NAMESPACE

Command options

NAMESPACE
The name or ID for a namespace. This value is required.

Example

ibmcloud fn namespace target HBCTeamProd

ibmcloud fn namespace update

Change the name or description of an IAM namespace.

ibmcloud fn namespace update NAMESPACE [NEW_NAMESPACE_NAME] [--description DESCRIPTION]

Command options

NAMESPACE
The name for a namespace. Do not include hyphens (-) in the name. This value is required.
NEW_``NAMESPACE``_NAME
The new name for a namespace. Do not include hyphens (-) in the name. This value is optional.
--description DESCRIPTION, -n DESCRIPTION
Write your own unique description to help you identify the namespace. If your description is more than one word, include quotation marks (") around your description. This value is optional.

Example

ibmcloud fn namespace update HBCTeamProd HBCTeamStaging

Package commands

Create, update, delete, bind, and find information about packages.

To see CLI help for the package command, run ibmcloud fn package.

ibmcloud fn package bind

Bind parameters to a package. All the actions within the package inherit those parameters unless otherwise specified.

ibmcloud fn package bind PACKAGE_NAME BOUND_PACKAGE_NAME [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--param KEY VALUE] [--param-file FILE]

Command options

PACKAGE_NAME
The name of the package. This value is required.
BOUND_PACKAGE_NAME
The name of the package binding. This value is required.
--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.

Example

ibmcloud fn package bind hellopkg hellopkgbind --param name Bob

ibmcloud fn package create

Create a package designed to contain one or more actions. To add an action in the package, include the package name with the action name when you create or update the action.

ibmcloud fn package create PACKAGE_NAME [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--param KEY VALUE] [--param-file FILE]

Command options

PACKAGE_NAME
The name of the package. This value is required.
--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS VALUE format. This value is optional.
--shared yes|no
When specified without a value or with a value of yes, the package is shared with other users.

Example

ibmcloud fn package create hellopkg

Output

ok: created hellopkg

ibmcloud fn package delete

You can clean up your namespace by deleting packages that you do not want to use any longer.

ibmcloud fn package delete PACKAGE_NAME

Example

ibmcloud fn package delete hello

Output

ok: deleted hello

ibmcloud fn package get

Get metadata that describes a specific package.

ibmcloud fn package get PACKAGE_NAME [--summary]

Command options

PACKAGE_NAME
The name of a package. This value is required.
--summary
Get a summary of the package details. Parameters with the prefix "*" are bound. This value is optional.

Example

ibmcloud fn package get hello

ibmcloud fn package list

List all the packages that you created or a specific number of packages.

ibmcloud fn package list [NAMESPACE] [--limit NUMBER_OF_PACKAGES] [--name-sort] [--skip NUMBER_OF_PACKAGES]

Command options

/NAMESPACE
List the packages in a specific namespace ID. This value must begin with a /. This value is optional. If not specified, all packages are listed.
--limit NUMBER_OF_PACKAGES, -l NUMBER_OF_PACKAGES
List a specified number of packages. The default is 30 packages.
--name-sort, -n
Sort the list of returned packages by name, otherwise the list is sorted by creation date.
--skip NUMBER_OF_PACKAGES, -s NUMBER_OF_PACKAGES
Exclude a specified number of the most recently created packages from the result.

Example

ibmcloud fn package list

Run ibmcloud fn package list /whisk.system to view a list of preinstalled packages.

ibmcloud fn package refresh

Refresh the package bindings for all the packages within a specific namespace.

ibmcloud fn package refresh /NAMESPACE

Command options

/NAMESPACE
A namespace ID, beginning with /. This value is required. Run ibmcloud fn namespace list to get a list of namespaces to choose from.

Example

ibmcloud fn package refresh /user@domain.com_dev

ibmcloud fn package update

Update a package designed to contain one or more actions. To add an action in the package, include the package name with the action name when you create or update the action.

When you update parameters for a package or action, you must specify all previously created parameters. Otherwise, the previously created parameters are removed. For packages, any services that were bound to the package are also removed, so after you update other parameters you must bind services to your package again.

ibmcloud fn package update PACKAGE_NAME [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--param KEY VALUE] [--param-file FILE]

Command options

PACKAGE_NAME
The name of the package. This value is required.
--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--shared yes|no
When specified without a value or with a value of yes, the package is shared with other users.

Example

ibmcloud fn package create hellopkg

Output

ok: created hellopkg

Property commands

Set global properties for your CLI environment or view properties about the wsk CLI, which runs as part of the ibmcloud fn CLI.

To see CLI help for the property command, run ibmcloud fn property.

ibmcloud fn property get

View the metadata details for a property from the wsk CLI.

ibmcloud fn property get [--apihost HOST] [--apiversion VERSION] [--auth KEY] [--cert STRING] [--key STRING] [--namespace NAMESPACE]

Command options

--all
View all properties for the wsk CLI. This value is optional.
---apibuild
The wsk API build information. This value is optional.
--apibuildno
The wsk API build number. This value is optional.
--apihost HOST
The wsk API host. This value is optional.
--apiversion VERSION
The wsk API version. This value is optional.
--auth KEY, -u KEY
The wsk authorization KEY. This value is optional.
--cert STRING
The wsk client certificate. This value is optional.
--cliversion
The wsk CLI version. This value is optional.
--key STRING
The wsk client KEY. This value is optional.
--namespace NAMESPACE
An IAM namespace name or ID. This value cannot be set for Cloud Foundry namespaces. This value is optional.

Example

ibmcloud fn property get --auth

ibmcloud fn property set

Set a property. At least one option is required. After a property is set, it is retained on your workstation at <home_dir>/.bluemix/plugins/cloud-functions/config.json. To remove a property, run ibmcloud fn property unset --<property>.

You can target a Cloud Foundry-based namespace by running ibmcloud fn property set --namespace <namespace_name_or_ID>.

ibmcloud fn property set [--auth KEY] [--cert STRING] [--key STRING] [--namespace NAMESPACE]

Command options

--auth KEY, -u
The wsk authorization KEY. This value is optional.
--cert STRING
The wskclient certificate. This value is optional.
--key STRING
The wsk client KEY. This value is optional.
--namespace NAMESPACE
An IAM-enabled namespace name or ID, or Cloud Foundry-based namespace name.

Example

ibmcloud fn property set --namespace myNamespace

Output

ok: whisk namespace set to myNamespace

ibmcloud fn property unset

Unset a property for the wsk CLI. At least one value is required.

If properties are retained after running the property unset command, you can delete the config.json file located at <home_dir>/.bluemix/plugins/cloud-functions/config.json to remove all properties.

ibmcloud fn property unset [--apihost HOST] [--apiversion VERSION] [--auth KEY] [--cert STRING] [--key STRING] [--namespace NAMESPACE]

Command options

--apihost HOST
The wsk API host. This value is optional.
--apiversion VERSION
The wsk API version. This value is optional.
--auth KEY, -u
The wsk authorization KEY. This value is optional.
--cert STRING
The wsk client certificate. This value is optional.
--key STRING
The wsk client KEY. This value is optional.
--namespace NAMESPACE
An IAM namespace name or ID. This option cannot be set for Cloud Foundry namespaces. This value is optional.

Example

ibmcloud fn property unset --namespace

Rule commands

Create, delete, enable, disable, update, and find information about rules.

To see CLI help for the rule command, run ibmcloud fn rule.

ibmcloud fn rule create

Create a rule to associate a trigger with an action. Before you can create a rule, create a trigger and an action first.

ibmcloud fn rule create RULE_NAME TRIGGER_NAME ACTION_NAME

Example

ibmcloud fn rule create myrule mytrigger myaction

Output

ok: created myrule

ibmcloud fn rule delete

To clean up your namespace, remove rules you no longer need.

ibmcloud fn rule delete RULE_NAME [--disable]

Command options

RULE_NAME
The name of a rule. This value is required.
--disable
Disable the rule before you delete it.

Example

ibmcloud fn rule delete myrule

ibmcloud fn rule disable

Change the status of a rule to inactive and stop it from running an action when a trigger is fired.

ibmcloud fn rule disable RULE_NAME

Example

ibmcloud fn rule disable myrule

ibmcloud fn rule enable

Change the status of a rule from inactive to active. When active, an action runs when a trigger is fired.

ibmcloud fn rule enable RULE_NAME

Example

ibmcloud fn rule enable myrule

ibmcloud fn rule get

Get metadata that describes a specific rule.

ibmcloud fn rule get RULE_NAME [--summary]

Command options

RULE_NAME
The name of a rule. This value is required.
--summary
Get a summary of the rule details.

Example

ibmcloud fn rule get myrule

ibmcloud fn rule list

List all the rules that you created or a specific number of rules.

ibmcloud fn rule list RULE_NAME [--limit NUMBER_OF_RULES] [--name-sort] [--skip NUMBER_OF_RULES]

Command options

RULE_NAME
The name of a rule. This value is optional. If not specified, all rules are listed.
--limit NUMBER_OF_RULES, -l NUMBER_OF_RULES
List a specified number of rules. The default is 30 rules.
--name-sort, -n
Sort the list of returned rules by name, otherwise the list is sorted by creation date.
--skip NUMBER_OF_RULES, -s NUMBER_OF_RULES
Exclude a specified number of the most recently created rules from the result.

Example

ibmcloud fn rule list

ibmcloud fn rule status

See whether a rule is active or inactive. Run the ibmcloud fn rule disable or ibmcloud fn run enable commands to change the status.

ibmcloud fn rule status RULE_NAME

Example

ibmcloud fn rule status myrule

ibmcloud fn rule update

To change which triggers are associated with which rules, you can update a rule.

ibmcloud fn rule update RULE_NAME TRIGGER_NAME ACTION_NAME

Example

ibmcloud fn rule update myrule mytrigger myaction

SDK command

Install SDK components, such as docker, iOS, and bashauto.

To see CLI help for the sdk command, run ibmcloud fn sdk.

ibmcloud fn sdk install

Install an SDK.

ibmcloud fn sdk install COMPONENT [--limit NUMBER_OF_TRIGGERS]

Command options

COMPONENT
The SDK component, such as docker, iOS, and bashauto. This value is required.
--stdout, --s
Prints the bash command results to STDOUT. This value is optional.

Example

ibmcloud fn sdk install docker

Service commands

Service commands bind and unbind service credentials to an action or package.

To see CLI help for the service command, run ibmcloud fn service.

If you receive the error Unable to refresh user access token: CloudFoundry API endpoint is not set when running the service command, run ibmcloud target --cf.

ibmcloud fn service bind

Bind service credentials to an action or package.

ibmcloud fn service bind SERVICE PACKAGE_or_ACTION_NAME [--instance SERVICE_INSTANCE] [--keyname SERVICE_KEY]

Command options

SERVICE
The name of the service.
PACKAGE_or_ACTION_NAME
The name of the package or action to bind the credentials to.
--instance SERVICE_INSTANCE
The service instance name.
--keyname SERVICE_KEY
The name of the service KEY credentials to bind.

Example

ibmcloud fn service bind cloudant hello --instance CLOUDANT_SERVICE

ibmcloud fn service unbind

Unbind service credentials from an action or package.

ibmcloud fn service unbind SERVICE PACKAGE_or_ACTION_NAME

Command options

SERVICE
The name of the service.
PACKAGE_or_ACTION_NAME
The name of the package or action to unbind the credentials from.

Example

ibmcloud fn service unbind cloudant hello

Trigger commands

Create, update, delete, fire, and find information about triggers.

To see CLI help for the trigger command, run ibmcloud fn trigger.

ibmcloud fn trigger create

Create a trigger.

ibmcloud fn trigger create TRIGGER_NAME [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--feed ACTION_NAME] [--param KEY VALUE] [--param-file FILE] [--trigger-param KEY VALUE] [--feed-param KEY VALUE]

Command options

TRIGGER_NAME
The name of the trigger. This value is required.
--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
--feed ACTION_NAME, -f ACTION_NAME
Sets the type of trigger as a feed. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--trigger-param KEY VALUE, -p KEY VALUE
Trigger parameter values in the KEY VALUE format. This value is optional.
--feed-param KEY VALUE, -p KEY VALUE
Feed parameter values in the KEY VALUE format. This value is optional.

Examples

ibmcloud fn trigger create mytrigger --param name Bob 
ibmcloud fn trigger create mytrigger --trigger-param name Bob

Starting in functions plug-in CLI version 1.0.38, two new options are available for the trigger command: --trigger-param and --feed-param. These options are an extension to creating and updating a trigger, making the trigger create and update commands more flexible.

Previously, you created and updated a trigger with a parameter on it with the following command:

ibmcloud fn trigger create triggerHelloWorld --param msg “Hello World!” 

This command creates a trigger called triggerHelloWorld with a parameter of KEY msg and VALUE of Hello World!. This is very simple and straightforward. However, it becomes a little complicated when you create a trigger that contains a feed, especially when you want to add parameters on both the trigger and the trigger feed. For example, if you want to create a trigger with alarm feed, then you must run a command similar to the following example:

ibmcloud fn trigger create triggerCron --feed /whisk.system/alarms/alarm --param cron “0,1,2,3,4,5”

In this case, the KEY and VALUE pair that follows --param are consumed by feed and are treated as feed parameters. By using the new options, you can differentiate between trigger parameters and feed parameters. The following command creates a trigger called triggerCron with cron feed parameters of 0,1,2,3,4,5 and a trigger parameter of KEY msg and VALUE of Hello World!.

ibmcloud fn  trigger create triggerCron --feed /whisk.system/alarms/alarm --feed-param cron “0,1,2,3,4,5” --trigger-param msg “Hello World!”

The original --param option is not deprecated so you can continue to use it as you have previously. You simply now have the ability to separate your trigger and feed parameters by using the new options. However, please do not mix --param or --param-file options with either --trigger-param or --feed-param options. These options are considered two different ways of setting trigger parameters and must not be used together.

ibmcloud fn trigger delete

Delete a trigger.

ibmcloud fn trigger delete TRIGGER_NAME

Example

ibmcloud fn trigger delete mytrigger

ibmcloud fn trigger fire

Test a trigger by firing it, rather than waiting for it to be triggered automatically.

ibmcloud fn trigger fire TRIGGER_NAME [--param KEY VALUE] [--param-file FILE]

Command options

TRIGGER_NAME
The name of the trigger. This value is required.
--param KEY VALUE, -p KEY VALUE
Parameter VALUES in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.

Example

ibmcloud fn trigger fire --param name Bob

ibmcloud fn trigger get

Get metadata that describes a specific trigger.

ibmcloud fn trigger get TRIGGER_NAME [--summary]

Command options

TRIGGER_NAME
The name of a trigger. This value is required.
--summary
Get a summary of the trigger details.

Example

ibmcloud fn trigger get mytrigger

ibmcloud fn trigger list

List all the triggers that you created or a specific number of triggers.

ibmcloud fn trigger list TRIGGER_NAME [--limit NUMBER_OF_TRIGGERS] [--name-sort] [--skip NUMBER_OF_TRIGGERS]

Command options

RULE_NAME
The name of a trigger. This value is optional. If not specified, all triggers are listed.
--limit NUMBER_OF_TRIGGERS, -l NUMBER_OF_TRIGGERS
List a specified number of triggers. The default is 30 triggers.
--name-sort, -n
Sort the list of returned triggers by name, otherwise the list is sorted by creation date.
--skip NUMBER_OF_TRIGGERS, -s NUMBER_OF_TRIGGERS
Exclude a specified number of the most recently created triggers from the result.

Example

ibmcloud fn trigger list

ibmcloud fn trigger update

Update a trigger.

When you update trigger parameters (Note: this is different than trigger feed parameters) that use the --trigger-parameter or --param-file option, you must specify all previously created parameters. Otherwise, the previously created parameters are removed. For more information, see Create trigger.

ibmcloud fn trigger update TRIGGER_NAME [--annotation ANNOTATION_KEY ANNOTATION_VALUE] [--annotation-file FILE] [--param KEY VALUE] [--param-file FILE] [--trigger-param KEY VALUE] [--feed-param KEY VALUE]

Command options

TRIGGER_NAME
The name of the trigger. This value is required.
--annotation ANNOTATION_KEY ANNOTATION_VALUE, -a ANNOTATION_KEY ANNOTATION_VALUE
Annotations are specified in a KEY VALUE format. To include more than one annotation, specify this option for each annotation. This value is optional.
--annotation-file FILE, -A FILE
A JSON file that contains annotation in a KEY VALUE format. This value is optional.
--param KEY VALUE, -p KEY VALUE
Parameter values in the KEY VALUE format. This value is optional.
--param-file FILE, -P FILE
A JSON file that contains parameter KEYS and VALUES. This value is optional.
--trigger-param KEY VALUE, -p KEY VALUE
Trigger parameter values in the KEY VALUE format. This value is optional.
--feed-param KEY VALUE, -p KEY VALUE
Feed parameter values in the KEY VALUE format. This value is optional.

Examples

ibmcloud fn trigger update mytrigger --param name Jim
ibmcloud fn trigger update mytrigger --trigger-param name Jim
ibmcloud fn trigger update mytrigger --feed-param cron "0,1,2,3,4"