Updated on 2024-08-07 GMT+08:00

Configuring Dependency Packages

Overview

Generally, the code of a function consists of public libraries and service logic. The public libraries can be packaged as a dependency and shared among functions, reducing the size of the function code package for easy deployment and update.

FunctionGraph also provides some public dependencies, which are cached internally for quick loading. These dependencies are recommended.

FunctionGraph enables you to manage dependencies in a unified manner. You can upload dependencies from a local path, or through OBS if they are too large, and specify names for them. Dependencies can be iterated. Each dependency can have multiple versions.

For details, see How Do I Create Function Dependencies?

  • The name of each file in the dependency package cannot end with a tilde (~).
  • A dependency package can contain up to 30,000 files.
  • If your function uses a large private dependency, increase the execution timeout by choosing Configuration > Basic Settings on the function details page.

Creating a Dependency

  1. Log in to the FunctionGraph console, and choose Functions > Dependencies in the navigation pane.
  2. Click Create Dependency.
  3. Set the following parameters:

    Table 1 Dependency configuration parameters

    Parameter

    Description

    Name

    Dependency name.

    Code Entry Mode

    Upload a ZIP file directly or upload a file from OBS.

    • Upload ZIP: Click Select File to upload one.
    • Upload from OBS: Specify an OBS link URL.

    Runtime

    Select a runtime.

    Description

    Description of the dependency. This parameter is optional.

  4. Click OK. By default, a new dependency is version 1.
  5. Click the dependency name, and view all versions and related information on the displayed page. Each dependency can have multiple versions.

    • To create a dependency version, click Create Version in the upper right corner of the page.
    • To view the address of a version, click the version.
    • To delete a version, click the delete icon in the same row.
      Figure 1 Deleting a dependency version

Configuring Dependencies for a Function

  1. Return 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. On the displayed Select Dependency dialog box, select dependencies 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.

    Name

    Select a dependency.

    Version

    Select a version to be added.

    • You can add a maximum of 20 dependencies for a function.
    • Except your private dependencies, FunctionGraph provides some public dependencies, which you can choose when creating a function.

Deleting a Dependency

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

  1. Return to the FunctionGraph console, and choose Functions > Dependencies in the navigation pane.
  2. Click the name of the target dependency to go to the Versions page.
  3. Click the delete icon in the row of a version. Repeat this operation if the dependency has multiple versions.

    Figure 2 Deleting a dependency version

    Dependencies referenced by functions cannot be deleted.