Updated on 2025-03-13 GMT+08:00

Step 2: Host Function Code

  1. On the DevCloud console, choose Code > CodeHub, and click Create Directly.

    Create a code repository named functions, and retain the default settings for other parameters.

  2. Go to the functions repository created in 1. Create the deploy directory for storing the function deployment script deploy.py.
    Figure 1 Creating a directory

    The deploy.py script will read the function configuration file cam.yaml and construct an hcloud command to update the function code and configuration. For details about the configurations in cam.yaml, see Analyzing cam.yaml. Logs generated when executing this script will be recorded in the /home/function/deploy/function.log file.

  3. Create another directory named helloworld, with a complete structure.
    Figure 2 Complete function directory structure
    • helloworld: the helloworld function
    • cam.yaml: the configuration file
    • code: function code directory, which stores the index.py file