This topic describes how to use Funcraft to manage functions. In this topic, a demo function whose output is Hello World is created.

Notice This topic is no longer maintained. If you use Funcraft to manage your Function Compute resources, we recommend that you migrate your resources to Serverless Devs and use Serverless Devs to manage your resources.

For more information about how to migrate Function Compute-related resources from Funcraft to Serverless Devs, see Migrate resources from Funcraft to Serverless Devs.

For more information about how to use Serverless Devs to manage functions, see Quick start.

We apologize for any inconvenience caused.

Background information

Funcraft is an application deployment tool provided by Function Compute. You can use Funcraft to manage resources of services such as Function Compute, API Gateway, and Log Service with ease and deploy applications with high efficiency. For more information about Funcraft, see Features.

Try Funcraft in Cloud Shell


The following operations are complete:


  1. Create a template for initialization.
    1. Run the following command to initialize the project template:
      fun init -n demo
    2. Select a project template as prompted.
      ? Select a template to init (Use arrow keys or type to search)
      > event-nodejs12
      (Move up and down to reveal more choices)
      The following types of project templates are available:
      • Templates prefixed with event- are regular event functions.
      • Templates prefixed with http-trigger automatically create HTTP triggers. An HTTP trigger uses Request and Response as input parameters to help you create a web application.

      In this example, event-nodejs10 is used.

      Funcraft creates a demo folder in the directory where you run the command. The demo folder contains the index.js and template.yml files.

      • The index.js file contains the sample code of the function.
      • The template.yml file contains the information about the function.
        • In this example, the demo service and the demo function are created.
        • For more information about the configuration items that are supported by the template.yml file, see Serverless Application Model.
  2. Optional:Debug the function on your on-premises device.

    To debug the function on your on-premises device, you must first install Docker on your on-premises device. For more information, see Install Docker. If you cannot install Docker on your on-premises device, skip this step and debug the function in the Function Compute console.

    1. Run the following command to access the demo function:
      cd demo
    2. Run the following command on your on-premises device to debug the function:
      fun local invoke demo
      Note The first time you debug the function, the image of the invocation environment is pulled to your on-premises device. This takes a long time to complete.
  3. Deploy the function to Function Compute.
    1. Run the following command to deploy the function to Function Compute:
      fun deploy
    2. During the deployment, enter Y to confirm the resources that you want to create.
      After the resources are created, the service demo deploy success message appears. The message indicates that your resources are deployed.
  4. Test the result in Function Compute.

    You can log on to the Function Compute console to check whether the preceding deployment is successful.

    1. Log on to the Function Compute console.
    2. In the left-side navigation pane, click Services and Functions.
    3. In the top navigation bar, select the region where the service resides.
    4. On the Services page, click the target service.
    5. On the Functions page, click the name of the function that you want to manage.
    6. On the Code tab of the details page of the function, click Test Function to execute the function in the Function Compute console.
  5. View logs.

    After the function is executed, you can view the execution log on the Code tab. To view historical execution logs, you must first configure a Logstore for the function. Then, you can view historical execution logs on the Logs tab. For more information, see Configure logging.

What to do next

After you complete the preceding steps, you can read the following topics based on your business scenarios to perform more advanced operations: