Skip to main content

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:

ParameterDescriptionDefault Value
-l, --limit <limit>Returned data length20
-o, --offset <offset>Data offset0

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:

ParameterDescriptionRequired
functionNameFunction nameYes
destPathDownload destination pathNo

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:

ParameterDescriptionRequired
functionNameFunction nameYes
-e, --env-id <envId>Environment IdNo
--deployMode <deployMode>Deployment mode: cos (default), zip (limited to 1.5 MB)No
--yesSkip interactive confirmationNo

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:

ParameterDescriptionRequired
functionNameFunction NameNo (If not specified, all functions in the configuration file will be deleted)
-e, --env-id <envId>Environment IDNo
--forceForce deletion and skip confirmation promptsNo
--dry-runSimulate the operation to preview functions to be deleted without actual executionNo

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:

ParameterDescriptionRequired
functionNameFunction nameYes
descriptionVersion descriptionNo

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 destPath is not specified, the code will be downloaded to the directory configured by functionRoot.
  • After downloading, a folder named after the function will be automatically created.

Difference Between code update and deploy:

  • tcb fn code update only updates the function code and execution entry point, which is faster
  • tcb fn deploy updates 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 --force parameter 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 download to 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 $LATEST version (the latest version) by default
  • Only the $LATEST version's configuration and code can be modified
  • When publishing a new version, an immutable snapshot is created based on the current $LATEST version
  • Published version numbers increment sequentially (1, 2, 3...), and their content cannot be modified