Management
Cloud Functions are pieces of code that run in the cloud, requiring no server management. Developers can write code within development tools and deploy backend code with one-click upload. Cloud Functions in Cloud Development allow users to upload their business logic code. These functions can be triggered via Cloud Development invocations to implement backend business operations.
View functions
You can use the following command to list all Cloud Functions and view their basic information:
tcb fn list
You will see output similar to the following:

Specify the number of returned items and offset
By default, the fn list command lists only the first 20 functions. If you have more functions and need to list additional ones, you can use the following options to specify the data length and offset for the command's return:
-l, --limit <limit> Number of returned data items, default value is 20
-o, --offset <offset> Data offset, default value is 0
For example:
# Return information for the first 10 functions
tcb fn list -l 10
# Return information for functions 3 - 22 (including 3 and 22)
tcb fn list -l 20 -o 2
Downloading Cloud Function Code
You can download Cloud Function code using the following command:
tcb fn code download <functionName> [destPath]
By default, function code is downloaded to functionRoot in a folder named after the function. You can specify the destination folder path, and all code files for the function will be downloaded directly to the specified folder.
Triggering Functions
You can locally trigger your cloud functions directly via Cloudbase CLI:
# Triggering the app Function
tcb fn invoke app
# Triggering All Functions in the Configuration File
tcb fn invoke
Passing Parameters When Triggering Functions
# Triggering the app Function and Passing Parameters
tcb fn invoke app --params '{"key1": "value1", "key2": "value2"}'
If you are using a Windows system, you need to wrap the parameter string in double quotes and escape the double quotes using \, for example:
tcb fn invoke app --params "{\"key1\": \"value1\", \"key2\": \"value2\"}"
Viewing Function Details
As mentioned earlier, the fn list command can only display basic information about functions. If you wish to view detailed information about functions, you can use the following command:
# Viewing app Function Details
tcb fn detail app
Output
Status: Deployment completed
Code size (B): 1695
Environment variables (key=value): key=value
Function name: test
Handler: index.main
Memory configuration (MB): 256
Modified time: 2019-08-19 21:15:39
Environment Id: dev-xxx
Runtime environment: Nodejs10.15
Timeout (S): 20
Network configuration: None
Trigger:
myTrigger:{"cron": "0 0 2 1 * * *"}
Function code (Java functions and functions with an entry point larger than 1 M will not be displayed):
'use strict';
exports.main = async (event, context, callback) => {
console.log(event);
return 'hello world'
};
Delete function
You can delete the function using the following command
# Delete app function
tcb fn delete app
# Delete all functions in the configuration file
tcb fn delete
Copy function
You can quickly copy an existing function using the following command:
# Copy the app function as the app2 function
tcb fn copy app app2
When using the fn copy command, you must specify the source function name and the new function name after copying. The current environment Id and target environment environment Id are optional. If no target environment Id is specified, the function will be copied to the current environment.
If the name of the new function already exists, the copy operation will be aborted. If you want to overwrite the existing function, you can use the following command
Overwrite function with the same name
# Copy the app function as app2, overwriting if it exists
tcb fn copy app app2 --force
Note: The copy function operation does not copy function triggers.