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


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

Step 1: Prepare the environment

An easy and simple way to install Funcraft is to download the executable binary files.

  1. Install Funcraft on the local machine. For more information, see installation instructions.
  2. Run fun --version to check whether the installation is successful.
  3. Run fun config to configure Funcraft. Then configure Account ID, Access Key ID, Access Key Secret, and Default region name 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 machine.
    git clone https://          
    Note If you do not have git installed, enter in the address bar of your browser. Click the download button to download directly.
  2. Run the following command to access the cloned sample project:
    cd fc-custom-demo
    cd ruby-demo        
  3. Run the following command to deploy the project to Function Compute:
    fun deploy -y     
    The following result is returned:
    Waiting for service ruby-demo to be deployed...
            Waiting for function fc-ruby to be deployed...
                    Waiting for packaging function fc-ruby code...
                    The function fc-ruby has been packaged. A total of 4 files were compressed and the final size was 1.45 KB
            function fc-ruby deploy success
    service ruby-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: a9c4dc8a-4b5b-48e0-9a3f-70310531ae61
    Hello World
    FC Invoke End RequestId: a9c4dc8a-4b5b-48e0-9a3f-70310531ae61
    Duration: 0.69 ms, Billed Duration: 100 ms, Memory Size: 512 MB, Max Memory Used: 5.06 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    Hello World