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

Uploading Function Code from OBS

This section describes how to upload a function code file stored in OBS to the FunctionGraph console.

Scenarios

On the FunctionGraph console, you can upload a ZIP file (up to 300 MB) in an OBS bucket by specifying its OBS link URL to deploy your function code.

All runtimes support function code upload from OBS. For details about how to package a function project, see Function Project Packaging Rules.

Notes and Constraints

  • Ensure that the OBS bucket is in the same region as the function.
  • If the size of the code file in the OBS bucket exceeds 300 MB or the size of the source code after decompression exceeds 1.5 GB, submit a service ticket.
  • 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

Prerequisites

You have uploaded the function code file to an OBS bucket and granted the read permission on the object to anonymous users. For details, see Granting All Accounts the Read Permission for Certain Objects.

Uploading Function Code

  1. Log in to the OBS console. Copy the URL of the code file object by referring to Sharing Objects with Anonymous Users Using URLs.
  2. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  3. Click a function name to go to the function details page.
  4. Click the Code tab and choose Upload > OBS ZIP.
  5. In the displayed dialog box, enter the copied OBS bucket object URL.
  6. 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"
              }
          ]
      }

  7. After the OBS address is entered, 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.