Bind Integration to Cloud Function
For ready-to-use cloud function template code (including WeChat Pay, Official Account OAuth, and other scenarios — with cloud function source, frontend sample, and minimal runnable demo), see Sample Projects & References and clone the official example projects.
Use the tcb integration bind-resource command to bind an integration to a cloud function, establishing the association between business logic and the integration.
tcb integration bind-resource <keyId> --function <function-name>
Command Parameters
| Parameter | Description | Required |
|---|---|---|
<keyId> | Integration Key ID (positional) | Yes |
--function <functionName> | Cloud function name to bind | Yes |
--json | Output results in JSON format | No |
--yes | Skip interactive confirmation | No |
Note: The integration instance is specified by the positional argument
<keyId>. The--nameoption is not supported (because name is not unique, there may be multiple integrations with the same name).
Usage Examples
Bind by Key ID
tcb integration bind-resource key-721a6e232e169382d3cbc5faa3dc2cd6 --function my-function
JSON Format Output
tcb integration bind-resource key-xxx --function my-function --json
Automation Script
In CI/CD pipelines, it is recommended to use the --yes parameter to skip interactive confirmation:
tcb integration bind-resource key-xxx --function my-function --yes
Output Examples
Standard Output
✓ Cloud function bound successfully
Integration info:
Key ID: key-721a6e232e169382d3cbc5faa3dc2cd6
Name: my-integration
Bound cloud function: my-function
Next steps:
Use 'tcb integration get key-721a6e232e169382d3cbc5faa3dc2cd6' to view details
Use 'tcb fn invoke my-function' to test the cloud function
JSON Output
{
"RequestId": "abc-123-def-456"
}
How It Works
After binding a cloud function, the integration establishes an association with the specified cloud function:
- Integration config passing: The integration's configuration (such as AppId, AppSecret, etc.) is passed to the cloud function
- Business logic execution: The cloud function can use the integration configuration to execute corresponding business logic
- Permission management: Unified permission management and control is achieved through integration binding
Notes
- Ensure the cloud function is deployed before binding
- One integration can only bind to one cloud function
- Repeated binding will overwrite the previous binding relationship
- After binding, you can view the bound cloud function name in the integration details
Unbind Cloud Function
To unbind a cloud function, you can edit the cloudbaserc.json configuration file, remove the demoCodeFunctionName field from the corresponding integration, and then execute:
# Push configuration to the cloud
tcb config update integration <keyId>
Tip: You can also unbind through the console.