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

Uploading Function Code

This section describes how to upload a function code file on the FunctionGraph console for deployment.

Scenarios

If the function code file is no more than 40 MB, you can upload a local ZIP or JAR file on the FunctionGraph console. For details about the types of code files that can be directly uploaded, see Table 1. For details about how to package code files, see Function Project Packaging Rules.
Table 1 File types that can be directly uploaded

Runtime

Uploading a ZIP File

Uploading a JAR File

Description

Node.js

Supported

Not supported

-

Python

Supported

Not supported

When you write code in Python, do not name your dependency package with the same suffix as a standard Python library, such as json, lib, and os. Otherwise, an error indicating a module loading failure will be reported.

Java

Supported

Supported

You can upload a ZIP or JAR file of Java code.

Uploading a JAR file

  • If no dependency is introduced, you can directly upload the JAR file of the function code.
  • If dependencies are introduced, you can configure them after creating a function and then upload the JAR file of the function code.

Uploading a ZIP file

If dependencies are introduced, you can create a ZIP file that contains all dependencies and the JAR file of the function code and upload the ZIP file. For details, see Developing Functions in Java (Using an IDEA Java Project) and Developing Functions in Java (Using an IDEA Maven Project).

Go

Supported

Not supported

Ensure that the name of the dynamic library file is consistent with the plug-in name of the handler. For example, if the name of the dynamic library file is testplugin.so, set the handler name to testplugin.Handler.

C#

Supported

Not supported

-

PHP

Supported

Not supported

-

Custom

Supported

Not supported

-

Cangjie

Supported

Not supported

-

Notes and Constraints

  • The code file to be uploaded cannot exceed 40 MB. If the file size exceeds 40 MB, upload it by following the instructions provided in Uploading Function Code from OBS.
  • If the code to be uploaded contains sensitive information (such as account passwords), encrypt the sensitive information to prevent leakage.
  • If the code deployed in the inline code editor is greater than 20 MB, the code is not displayed, as shown in Figure 1. However, the function code can still be tested.
    Figure 1 Code not displayed in the editor

Uploading Function Code

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click a function name to go to the function details page.
  3. Click the Code tab and choose Upload > Local ZIP or Upload > Local JAR.
  4. In the dialog box that is displayed, click Add and select the function code file.
  5. Use KMS static encryption to encrypt function code as required. (This feature is optional and available only in the LA-Sao Paulo1 region.)

    • functiongraph/default (default): The function automatically creates a default key in DEW.

      If you use the default key for encryption and decryption for the first time, ensure that the function agency has the following permissions: kms:dek:decrypt, kms:dek:create, kms:cmk:create, kms:cmk:get, and kms:cmk:list.

    • Customer master key (CMK): You can select a created key to encrypt the function code. For details about how to create a customer master key, see Creating a Custom Key.
      To use customer master key, ensure that the function agency has the following permissions: kms:dek:decrypt, kms:dek:create, kms:cmk:get and kms:cmk:list.

      If you select Customer master key (CMK), do not delete the CMK used for function encryption in DEW. Otherwise, the function execution will fail because encrypted data cannot be decrypted.

      Go to the IAM console and add the agency permission policy (using the default key as an example) to the function agency by referring to Configuring a Custom Policy in JSON View. Then, configure the agency permission for the function by referring to Configuring an Agency.
      {
          "Version": "1.1",
          "Statement": [
              {
                  "Action": [
                      "kms:dek:decrypt",
                      "kms:dek:create",
                      "kms:cmk:create",
                      "kms:cmk:get",
                      "kms:cmk:list"
                  ],
                  "Effect": "Allow"
              }
          ]
      }

  6. After the file is uploaded, click OK. The code is automatically deployed to the code editing area.

    If you need to modify the code in the code editing area, click Deploy each time after the modification is complete. For details about how to modify the function handler, see Modifying the Function Handler.