Skip to main content

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:

ParameterDescriptionDefault
-l, --limit <limit>Number of records to return20
-o, --offset <offset>Data offset0

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:

ParameterDescriptionRequired
functionNameFunction nameYes
destPathDownload destination pathNo

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:

ParameterDescriptionRequired
functionNameFunction nameYes
descriptionVersion descriptionNo

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

Difference between code update and deploy:

  • tcb fn code update only updates function code and entry point, faster
  • tcb fn deploy updates 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 --force parameter to force overwrite

Delete Cloud Function:

  • Deletion operation is irreversible, please operate with caution
  • Recommended to backup function code using tcb fn code download before deletion
  • After deletion, related triggers, logs, etc. will also be cleaned up

Version Management:

  • After function creation, it has a default $LATEST version (latest version)
  • Only $LATEST version configuration and code can be modified
  • When publishing new version, an immutable snapshot is created based on current $LATEST version
  • Published version numbers increment (1, 2, 3...), content cannot be modified