Cloud Function Management
Use cloud function management commands to view, invoke, copy, and delete cloud functions, as well as manage function versions.
View Function List
tcb fn list
Command Parameters:
| Parameter | Description | Default |
|---|---|---|
-l, --limit <limit> | Number of records to return | 20 |
-o, --offset <offset> | Data offset | 0 |
Usage Examples:
# View all functions
tcb fn list
# View first 10 functions
tcb fn list -l 10
# View functions 21-40
tcb fn list -l 20 -o 20
View Function Details
tcb fn detail <functionName>
Usage Example:
# View detailed information for app function
tcb fn detail app
Download Function Code
tcb fn code download <functionName> [destPath]
Parameter Description:
| Parameter | Description | Required |
|---|---|---|
functionName | Function name | Yes |
destPath | Download destination path | No |
Usage Examples:
# Download to default directory
tcb fn code download app
# Download to specified directory
tcb fn code download app ./my-functions/app
Update Function Code
tcb fn code update <functionName>
Usage Example:
# Update code for app function
tcb fn code update app
Invoke Cloud Function
# Invoke specified function
tcb fn invoke <functionName>
# Invoke all functions in config file
tcb fn invoke
Passing Parameters:
# Linux / macOS
tcb fn invoke app --params '{"key1": "value1", "key2": "value2"}'
# Windows (requires escaping double quotes)
tcb fn invoke app --params "{\"key1\": \"value1\", \"key2\": \"value2\"}"
Usage Examples:
# Invoke app function (no parameters)
tcb fn invoke app
# Invoke function with parameters
tcb fn invoke app --params '{"userId": "123", "action": "query"}'
# Invoke all functions
tcb fn invoke
Copy Cloud Function
tcb fn copy <sourceName> <targetName>
Usage Examples:
# Copy app function as app2
tcb fn copy app app2
# Force overwrite existing target function
tcb fn copy app app2 --force
Delete Cloud Function
# Delete specified function
tcb fn delete <functionName>
# Delete all functions in config file
tcb fn delete
Usage Examples:
# Delete app function
tcb fn delete app
# Delete all functions
tcb fn delete
Version Management
Publish New Version
tcb fn publish-version <functionName> [description]
Parameter Description:
| Parameter | Description | Required |
|---|---|---|
functionName | Function name | Yes |
description | Version description | No |
Usage Examples:
# Publish new version (no description)
tcb fn publish-version app
# Publish new version with description
tcb fn publish-version app "Fixed login logic issue"
# Publish version with feature update
tcb fn publish-version app "v1.2.0: Added user profiling feature"
View Version List
tcb fn list-function-versions <functionName>
Usage Example:
# View all versions of app function
tcb fn list-function-versions app
Important Notes
Download Function Code:
- If
destPathis not specified, code will be downloaded to directory configured infunctionRoot - After download, a folder named after the function will be automatically created
Difference between code update and deploy:
tcb fn code updateonly updates function code and entry point, fastertcb fn deployupdates code, configuration, and triggers, more comprehensive
Copy Cloud Function:
- Will copy function code, configuration (timeout, memory, environment variables, VPC, etc.), entry point, and runtime
- Will NOT copy function triggers, need manual configuration
- If target function name exists, use
--forceparameter to force overwrite
Delete Cloud Function:
- Deletion operation is irreversible, please operate with caution
- Recommended to backup function code using
tcb fn code downloadbefore deletion - After deletion, related triggers, logs, etc. will also be cleaned up
Version Management:
- After function creation, it has a default
$LATESTversion (latest version) - Only
$LATESTversion configuration and code can be modified - When publishing new version, an immutable snapshot is created based on current
$LATESTversion - Published version numbers increment (1, 2, 3...), content cannot be modified