云函数
#
Function#
Function.CallFunctionAsync#
1. 接口描述接口功能:调用云函数
接口声明:Task<FunctionResponse> CloudBaseApp.Function.CallFunctionAsync(string name, Dictionary<string, dynamic> param)
#
2. 输入参数字段 | 类型 | 必填 | 说明 |
---|---|---|---|
name | string | 是 | 云函数名称 |
param | object | 是 | 云函数参数 |
#
3. 输出参数#
FunctionResponse字段 | 类型 | 说明 | |
---|---|---|---|
Code | String | 状态码,操作成功则不返回 | |
Message | String | 错误描述 | |
RequestId | String | 请求序列号,用于错误排查 | |
Data | JObject | 云函数执行结果 |
#
4. 示例代码using System.Threading.Tasks;using System.Collections.Generic;using CloudBase;
// 匿名登录CloudBaseApp app = CloudBaseApp.Init("your-env-id", 3000);AuthState state = await app.Auth.GetAuthStateAsync();if (state == null) { await app.Auth.SignInAnonymouslyAsync();}
// 调用云函数var param = new Dictionary<string, dynamic>() { {"a", 1}, {"b", 2} };FunctionResponse res = await app.Function.CallFunctionAsync("sum", param);