You can install Fun on a computer running Linux, Mac OS X, or Windows. This topic describes how to install and configure Fun.

Prerequisites

  • Node.js v8.0.0 or a later version is installed on your computer. Fun uses Node.js to develop serverless applications. Click Node.js to download the Node.js installation package.
    • If your computer runs Linux or Mac OS X, we recommend that you use NVM to install Node.js. For more information, see Usage.
    • If your computer runs Windows, we recommend that you use Node.js Windows Installer to install Node.js.
  • Docker, which is used to build a local mock Link IoT Edge environment, is installed on your computer. For more information, see Docker Engine overview.

Install Fun

  1. Log on to your computer where Node.js and Docker are installed.
  2. Install Fun.
    npm install -g @alicloud/fun
  3. Check the installation result.
    fun --version

    If a version number is displayed, the installation is successful.

View help information

View help information about Fun.

Fun has provided extended features for you to develop and debug serverless applications in Link IoT Edge. To display help information about Fun and its sub-commands, use the -h or --help option.
Note You can also view help information about Fun in Fun.
$ fun --help
Usage: fun [options] [command]

The fun command line provides a complete set of commands to define, develop, and test serverless applications locally, and deploy them to the Alibaba Cloud.

Options:
  -v, --version  output the version number
  --verbose      verbose output
  -h, --help     output usage information

Commands:
  config         configure the fun
  init           initialize a new fun project
  install        install dependencies which are described in fun.yml
  build          build the dependencies
  local          run your serverless application locally
  edge           run your serverless application at edge
  validate       validate a fun template
  deploy         deploy a fun application
  help [cmd]     display help for [cmd]
Fun features extended for Link IoT Edge are provided by the fun edge sub-command.
$ fun edge --help
Usage: fun edge [options] [command]

Run your serverless application on the edge node (or in the local mock Link IoT Edge environment) for
quick development & testing.

Options:
  -h, --help  output usage information

Commands:
  invoke      invoke a function at edge once
  start       launch one local mock Link IoT Edge environment, or create one if none exist
  stop        stop the local mock Link IoT Edge environment
  help [cmd]  display help for [cmd]

Configure Fun

Before using Fun, you must configure required information, including the ID of your Alibaba Cloud account, the AccessKey ID and AccessKey secret, the default region where you use Fun, and the maximum number of retries for each SDK client. To configure the information, run the following command and then enter information as prompted:
fun config
The configuration process is similar to the following:
$ fun config
? Aliyun Account ID <Your Aliyun Account ID>
? Aliyun Access Key ID <Your Aliyun Access Key ID>
? Aliyun Secret Access Key <Your Aliyun Access Key Secret>
? Default region name <Your Default Region Name>
? The timeout in seconds for each SDK client invoking 10
? The maximum number of retries for each SDK client 6
The following parameters are required:
  • Aliyun Account ID: the ID of your Alibaba Cloud account. You can obtain the ID after logon to the Account Management console of Alibaba Cloud with the Alibaba Cloud account.Aliyun Account ID
  • Aliyun Access Key ID and Aliyun Secret Access Key: the AccessKey ID and AccessKey secret of your Alibaba Cloud account. For more information, see Create an AccessKey.

    If you used Alibaba Cloud CLI before, Fun automatically reads the AccessKey configuration from Alibaba Cloud CLI and uses the configuration.

  • Default region name: the default region where you use Fun. For more information about regions and zones, see Regions and zones.