Function Compute provides built-in common dependencies for you to reference in the runtime environment. Function Compute also supports third-party dependencies. This topic describes how to install third-party dependencies on Function Compute.

Background information

For more information about the common dependencies that are built in Function Compute, see the "Use built-in modules" section of the following topics:

Installation guide

You can install third-party dependencies by using one of the following methods:

  • Use the :
    • Install the dependencies by using a code package.
      1. Compress the third-party dependencies and code files into a package.
        Notice
        • You must compress all the files in the code directory into a package. After you compress the files, make sure that the files of the handler function are placed in the root directory of the package.
        • The packaging method varies with the operating system. Select a feasible packaging method as needed.
      2. Log on to the . Then, upload the on-premises code package to deploy functions. Alternatively, you can upload the code package to Object Storage Service (OSS) and import the code package from OSS.
    • Install the dependencies by using a terminal.
      If you use the new version of the online code editor in the Function Compute console, you can run the dependency installation command on the terminal on the Code tab to install the dependencies. For example, Python is used. Run the following command on the terminal in the new version of the online code editor to install the dependencies:
      pip install demo // Before you run this command, replace demo with the file name of the pip package.  
      Notice The new version of the online code editor is available only in the China (Shenzhen) region.

      If you need to use the new version of the online code editor as a RAM user, make sure that the AliyunRDCDevStudioRole policy is attached to the RAM user by using the Alibaba Cloud account to which the RAM user belongs. After the policy is attached, Function Compute can help you create an Apsara Devops account and initialize an Apsara DevOps organization workspace. For more information about the policy, see Policies and sample custom policies.

  • Use Funcraft: You can use Funcraft, a command line tool provided by Function Compute, to create and deploy functions. For more information, see Run the fun install command to install third-party dependencies.
  • Use Aliyun Serverless VSCode Extension: You can use Aliyun Serverless VSCode Extension to create and deploy functions. For more information, see Aliyun Serverless VSCode Extension.

References

For more information about how to install third-party dependencies in different runtime environments, see the "Use custom modules" section of the following topics: