You must configure Funcraft before you runfuncommands. This topic describes how to configure Funcraft.

Background information

You can use three methods to configure Funcraft. The priority of the three configuration methods increases in the following order:


For example, you usefun configto configureregionas cn-beijing, but a special project needs to be deployed to cn-shanghai. In this scenario, you can create a separate.envfile and writeREGION=cn-shanghaito it. Finally, runfun deployto deploy this project to cn-shanghai. In this way, you can deploy different projects to different regions.

By fun config

  1. Run the following command:
    fun config
  2. Set Account ID, AccessKey ID, AccessKey Secret, and Default Region Name in sequence as instructed.
    You can obtain Account ID and AccessKey ID from the Common Info section on the Overview page of the Function Compute console, as shown in the following figure:fun_config_accesskey
    After the configuration is completed, Funcraft saves the configuration to the.fcli/config.yamlfile.

By environment variables

In different operating systems, the steps of using environment variables to configure Funcraft are different:
Note If you configure Funcraft by setting environment variables, the configuration items are the same as those in the.envfile.
  • Linux and Mac
    • You can write environment variables into one line as follows:
      REGION=cn-beijing ACCOUNT_ID=xxx ACCESS_KEY_ID=xxx ACCESS_KEY_SECRET=xxx fun deploy
    • You can also write environment variables into multiple lines by using export as follows:
      export REGION=cn-beijing
      export ACCOUNT_ID=xxx
      export ACCESS_KEY_ID=xxx
      export ACCESS_KEY_SECRET=xxx
      fun deploy
  • Windows
    • If you use Command Prompt (CMD), set environment variables as follows:
      set REGION=cn-beijing
      set ACCOUNT_ID=xxx
      set ACCESS_KEY_ID=xxx
      set ACCESS_KEY_SECRET=xxx
      fun deploy
    • If you use PowerShell, set environment variables as follows:
      fun deploy

By the .env file

  1. In the project directory where thetemplate.ymlfile is located, create a file named.env.
    Note We recommend that you specify the path of the .envfile in the.gitignorefile to avoid account information leakage.
  2. In.envfile, enter the following configuration information: