You can use TypeScript to write functions in the Custom Runtime of Function Compute. This topic describes how to quickly deploy and call a TypeScript function.


You have installed Node.js 8.6.0 or later. For more information, see the official download page.
Note If you have installed Funcraft, go to Step 2: Deploy and call a function.

Step 1: Prepare the environment

The easiest way to install Funcraft is to download the executable binary files.

  1. Install Funcraft on the local machine. For more information, see Install Funcraft.
  2. Run the fun --version command to check whether the installation is successful.
  3. Run the fun config command to configure Funcraft. Set the Account ID, Access Key ID, Access Key Secret, and Default region name parameters as prompted.
    fun config
    Aliyun Account ID 1234xxx
    Aliyun Access Key ID xxxx
    Aliyun Access Key Secret xxxx
    Default region name cn-xxxx
    The timeout in seconds for each SDK client invoking 300
    The maximum number of retries for each SDK client 5
    Allow to anonynously report usage statistics to improve the tool over time? (Y/n)

Step 2: Deploy and call a function

  1. Run the following command to clone the sample project to your local device.
    git clone          
    Note If you have not installed Git, download it from and install it.
  2. Run the following command to access the cloned sample project:
    cd fc-custom-demo
    cd ts-demo        
  3. Run the following command to deploy the project to Function Compute:
    fun deploy -y          
    The following result is returned:
    Waiting for service ts-demo to be deployed...
            Waiting for function fc-ts to be deployed...
                    Waiting for packaging function fc-ts code...
                    The function fc-ts has been packaged. A total of 336 files were compressed and the final size was 9.41 MB
            function fc-ts deploy success
    service ts-demo deploy success 
  4. Run the following command to call the deployed function:
    fun invoke -e "Hello World"           
    The following result is returned:
    ========= FC invoke Logs begin =========
    FC Invoke Start RequestId: 7ab0a86a-be32-4086-ac17-3ce0797cda41
    Hello World
    FC Invoke End RequestId: 7ab0a86a-be32-4086-ac17-3ce0797cda41
    Duration: 13.48 ms, Billed Duration: 100 ms, Memory Size: 512 MB, Max Memory Used: 162.38 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    Hello World