Help Center/
FunctionGraph/
Developer Guide (Ally Region)/
Developing Functions/
Developing Functions in Cangjie/
Developing Functions in Cangjie (Using Visual Studio Code)
Updated on 2026-01-08 GMT+08:00
Developing Functions in Cangjie (Using Visual Studio Code)
- Cangjie functions can be developed only in the Linux environment.
- You can compile a function only via uploading a ZIP package with all required dependencies.
- Create a function project.
- Create a Cangjie project.
Figure 1 Creating a Cangjie project
- Add dependencies to the project.
- Configure dependencies.
In the module.json file of the user function, add the downloaded SDK on which the file depends.
{ "cjc_version": "0.xx.xx", "organization": "yuanrong", "name": "user_func_test", "description": "user func demo", "version": "1.0.0", "build_dir": "", "requires": {}, "dev_requires": {}, "package_requires": { "path_option":["./yuanrong_runtime_sdk"] }, "foreign_requires": {}, "output_type": "dynamic", "command_option": "", "condition_option": { "bind_now": "--link-options \"-z now\"" }, "link_option": "", "cross_compile_configuration": {}, "scripts": {}, "package_configuration": {} }
- Create a Cangjie project.
- Create a function.
- Create the funcdemo folder and create the success_invoke class in the package.
Figure 3 Creating the success_invoke class
- Define the function handler in success_invoke.cj.
package funcdemo from yuanrong_runtime_sdk import yuanrong_sdk.Context from yuanrong_runtime_sdk import yuanrong_sdk.APIGTriggerEvent from yuanrong_runtime_sdk import yuanrong_sdk.APIGTriggerResponse from yuanrong_runtime_sdk import yuanrong_sdk.FuncRegister from yuanrong_runtime_sdk import entry_macro.Entry from encoding import json.* from std import collection.* from std import os.* from serialization import serialization.* @Entry public func handleRequest(args: APIGTriggerEvent, context: Context): APIGTriggerResponse { var contextRunningTime: String = context.getRunningTimeInSeconds().toString() println("args is ${args.getBody()}") var resp = APIGTriggerResponse() resp.setBody(args.getBody()) resp.setStatusCode(200) resp }
- Create the funcdemo folder and create the success_invoke class in the package.
- Package the project files.
Use cjpm build to build a project.
- Create a Cangjie function by uploading the code package in ZIP format. For details, see section "Creating a Function from Scratch" in the FunctionGraph User Guide.
Compress the generated .so file and upload it to the Yuanrong environment.

Testing Function Invocation
- On the function details page, choose Code > Configure Test Event. In the dialog box that is displayed, click Create new test event > Blank Template.
The contents of the test cases are as follows:
{ "isBase64Encoded": false, "httpMethod": "POST", "path": "", "body": "test_cangjie" }
Parameters must be transferred based on the APIGTriggerEvent class defined in the Yuanrong SDK. Otherwise, serialization and deserialization exceptions may occur.public open class APIGTriggerEvent { private var isBase64Encoded: Bool = false; private var httpMethod: String = "POST"; private var path: String = ""; private var body: String = ""; } - After the test event is configured, click Test.
Parent topic: Developing Functions in Cangjie
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot
