SCF Management
Using SCF management commands, you can view, invoke, copy, and delete SCF functions, and manage function versions.
View Function List
tcb fn list
Command Parameters:
| Parameter | Description | Default Value |
|---|---|---|
-l, --limit <limit> | Returned data length | 20 |
-o, --offset <offset> | Data offset | 0 |
Usage Example:
# List All Functions
tcb fn list
# List the First 10 Functions
tcb fn list -l 10
# List Functions 21-40
tcb fn list -l 20 -o 20
View Function Details
tcb fn detail <functionName>
Usage Example:
# View app Function Details
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 Example:
# Download to the default directory
tcb fn code download app
# Download to the specified directory
tcb fn code download app ./my-functions/app
Update Function Code
tcb fn code update <functionName> [options]
Command Parameters:
| Parameter | Description | Required |
|---|---|---|
functionName | Function name | Yes |
-e, --env-id <envId> | Environment Id | No |
--deployMode <deployMode> | Deployment mode: cos (default), zip (limited to 1.5 MB) | No |
--yes | Skip interactive confirmation | No |
Usage Example:
# Update app Function Code
tcb fn code update app
# Update Code Using zip Mode
tcb fn code update app --deployMode zip
# Skip Confirmation and Update Directly
tcb fn code update app --yes
Invoke SCF
# Invoke Specified Function
tcb fn invoke <functionName>
# Invoke All Functions in Configuration File
tcb fn invoke
Parameters Passed:
# Linux / macOS
tcb fn invoke app --params '{"key1": "value1", "key2": "value2"}'
# Windows (Double Quotes Need Escaping)
tcb fn invoke app --params "{\"key1\": \"value1\", \"key2\": \"value2\"}"
Usage Example:
# Invoke app Function Without Parameters
tcb fn invoke app
# Invoke Function and Pass Parameters
tcb fn invoke app --params '{"userId": "123", "action": "query"}'
# Invoke All Functions
tcb fn invoke
Copying SCF
tcb fn copy <sourceName> <targetName>
Usage Example:
# Copy app Function to app2
tcb fn copy app app2
# Force overwrite existing target functions
tcb fn copy app app2 --force
Deleting SCF
# Delete Specified Function
tcb fn delete <functionName>
# Delete All Functions in Configuration File
tcb fn delete
Command Parameters:
| Parameter | Description | Required |
|---|---|---|
functionName | Function Name | No (If not specified, all functions in the configuration file will be deleted) |
-e, --env-id <envId> | Environment ID | No |
--force | Force deletion and skip confirmation prompts | No |
--dry-run | Simulate the operation to preview functions to be deleted without actual execution | No |
Usage Example:
# Deleting app Function
tcb fn delete app
# Delete All Functions
tcb fn delete
# Preview functions to be deleted (without actual execution)
tcb fn delete app --dry-run
# Force Delete, Skip Confirmation
tcb fn delete app --force
Version Management
Release a New Version
tcb fn publish-version <functionName> [description]
Parameter Description:
| Parameter | Description | Required |
|---|---|---|
functionName | Function name | Yes |
description | Version description | No |
Usage Example:
# Release a New Version (without description)
tcb fn publish-version app
# Release a New Version and Add Description
tcb fn publish-version app "Fixed login logic issues"
# Release a Version with Feature Updates
tcb fn publish-version app "v1.2.0: added new user profile feature"
View Version List
tcb fn list-function-versions <functionName>
Usage Example:
# View All Versions of the app Function
tcb fn list-function-versions app
Precautions
Download Function Code:
- If
destPathis not specified, the code will be downloaded to the directory configured byfunctionRoot. - After downloading, a folder named after the function will be automatically created.
Difference Between code update and deploy:
tcb fn code updateonly updates the function code and execution entry point, which is fastertcb fn deployupdates code, configuration, and triggers, providing a more complete feature set.
Copying SCF:
- Function code, configuration (timeout, memory, environment variables, VPC, etc.), execution entry point, and runtime will be copied
- Triggers of the function will not be copied and need to be manually configured
- If the target function name already exists, the
--forceparameter must be used to force overwrite
Deleting SCF:
- The deletion operation is irreversible; please proceed with caution.
- Before deletion, it is recommended to use
tcb fn code downloadto back up the function code - After deleting the function, related triggers, logs, etc. will also be cleaned up
Version Management:
- After a function is created, it has a
$LATESTversion (the latest version) by default - Only the
$LATESTversion's configuration and code can be modified - When publishing a new version, an immutable snapshot is created based on the current
$LATESTversion - Published version numbers increment sequentially (1, 2, 3...), and their content cannot be modified