Deploy Cloud Functions
Use the tcb fn deploy command to deploy cloud functions to CloudBase environment.
Basic Usage
# Deploy specified cloud function
tcb fn deploy <functionName>
# Deploy all cloud functions in config file
tcb fn deploy
Command Parameters
| Parameter | Description | Required |
|---|---|---|
-e, --envId <envId> | Environment ID | No |
--code-secret <codeSecret> | Code encryption key, 36 characters of uppercase/lowercase letters and numbers | No |
--force | Overwrite function if same name exists | No |
--path <path> | Automatically create HTTP access service path | No |
--all | Deploy all cloud functions in config file | No |
--dir <dir> | Specify cloud function folder path | No |
Usage Examples
# Deploy app function
tcb fn deploy app
# Deploy all functions
tcb fn deploy
# Deploy with code encryption
tcb fn deploy app --code-secret 7sGLwMnhgEfKmkqg2dMjB6xWk2hCxsAgGR6w
# Force overwrite function with same name
tcb fn deploy app --force
# Deploy with specified function directory
tcb fn deploy app --dir ./functions/app
Deployment Process
When executing the tcb fn deploy command, CLI automatically completes the following operations:
- Package and Upload: Package function code as a compressed file and upload
- Configuration Update: Update function configuration (timeout, memory, environment variables, network configuration, etc.)
- Trigger Deployment: Deploy or update triggers according to config file
Default Configuration
For Node.js cloud functions, CLI provides default configuration, deployment possible without manual configuration:
{
"timeout": 5,
"runtime": "Nodejs10.15",
"installDependency": true,
"handler": "index.main",
"ignore": ["node_modules", "node_modules/**/*", ".git"]
}
Important Notes
- Total function file size cannot exceed 50 MB
- After enabling code encryption, function code and information cannot be viewed in Mini Program IDE or Tencent Cloud Console
- Using
--forceparameter to overwrite will also overwrite function configuration and triggers - Environment variable configuration in
cloudbaserc.jsonwill completely overwrite online configured environment variables during deployment