Updated on 2025-08-19 GMT+08:00

Configuring a Dependency for a Function

This section describes how to create, configure, and delete a dependency on the FunctionGraph console.

Scenarios

Dependencies provide libraries, runtime environments, and extension capabilities for functions. For details about dependencies, see Overview.

Private dependencies must be created on the FunctionGraph console before being used. Public dependencies can be used directly. To use standard libraries and some built-in non-standard libraries in your function code, refer to Supported Dependency Libraries.

Notes and Constraints

  • You can add a maximum of 20 dependencies for a function.
  • Dependencies in use cannot be deleted.
  • Do not use the same directory or file name for dependencies and code files. For example, if depends.zip contains index.py and you use the inline editor with the handler index.handler, FunctionGraph will create another index.py file. This may cause file overwriting or merging errors.

Prerequisites

Before configuring a private dependency for a function, create one locally. For details, see Creating a Private Dependency for a Function.

Video Tutorial

This video shows how to upload a locally created private dependency and configure it for a function on the FunctionGraph console.

Creating a Dependency

The following procedure applies only to private dependencies. For public dependencies, you can perform operations in Configuring Dependencies.

  1. Log in to the FunctionGraph console, and choose Functions > Dependencies in the navigation pane.
  2. Click Create Dependency.
  3. Set the dependency parameters by referring to Table 1.

    Table 1 Dependency configuration parameters

    Parameter

    Description

    Name

    Dependency name.

    The value can contain a maximum of 96 characters, including letters, digits, underscores (_), periods (.), and hyphens (-). Start with a letter and end with a letter or digit.

    Runtime

    Runtime language of the dependency.

    You can select Cangjie, Node.js, Python, Java, PHP, Go, C#, or Custom.

    Code Entry Mode

    You can upload a ZIP file, write code online, or upload a ZIP file from OBS.

    • Upload ZIP: Click Add to upload a ZIP file. The maximum file size is 10 MB.
    • Upload from OBS: Enter the OBS link of the ZIP file in the OBS bucket. Note that the OBS bucket must be in the same region as the function. For details about how to upload an object to OBS, see Uploading an Object. For details about how to obtain the OBS link URL, see Accessing an Object Using a URL.
    • Online build: To use this feature, create a function agency with the SWR Admin permission.

      Currently, you can build dependencies online only for Node.js and Python. You only need to upload the package.json file for Node.js or the requirements.txt file for Python.

    Description

    Enter a description of the dependency.

  4. Click Create. The dependency details page is displayed. By default, a new dependency is version 1.

Creating a version for a dependency

On the dependency details page, view all versions and version information of the current dependency, as shown in Figure 1. Each dependency can have multiple versions.
  • To create a dependency version, click Create Version in the upper right corner of the page. The new version number is the current version number plus 1. After the creation is successful, the latest dependency version is displayed on the page by default.
  • Click a version number in the Version column to view the version information.
  • Click Download or Delete in the row where the version number is located to download or delete the version.
    Figure 1 Dependency version management

Configuring Dependencies

If the private dependency is large, you are advised to choose Configuration > Basic Settings on the function details page and extend the execution timeout to prevent function execution failures caused by timeout.

Procedure

  1. Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
  2. Click the name of the desired function.
  3. On the displayed function details page, click the Code tab, click Add in the Dependencies area.
  4. Select the dependency by referring to Table 2 and click OK.

    Table 2 Dependency configuration

    Parameter

    Description

    Runtime

    Runtime of this function. It cannot be changed.

    Type

    Add a Public or Private dependency.

    • Public: built-in dependency provided by FunctionGraph.
    • Private: dependency uploaded in Creating a Dependency.

    Name

    Select a dependency.

    Version

    Select a version to be added.

  5. Figure 2 shows the added dependency.

    Figure 2 Adding a dependency

Deleting a Dependency

To delete a dependency, just delete all of its versions.

  1. Log in to the FunctionGraph console, and choose Functions > Dependencies in the navigation pane.
  2. Click the dependency name. The dependency details page is displayed.
  3. As shown in Figure 3, click Delete in the row where the dependency version number is located under Versions to delete the version.

    Figure 3 Deleting a dependency version

Helpful Links

Manage function dependencies through APIs. For details, see Dependency APIs.