nav-img
Advanced

Creating a Deployment Package

To create a function, you must create a deployment package which includes your code and all dependencies. You can create a deployment package locally or edit code on the FunctionGraph console. If you edit code inline, FunctionGraph automatically creates and uploads a deployment package for your function. FunctionGraph allows you to edit function code in the same way as managing a project. You can create and edit files and folders. After you upload a ZIP code package, you can view and edit the code on the console.

Table 1 lists the code entry modes supported by FunctionGraph for each runtime.

Table 1 Code entry modes

Runtime

Editing Code Inline

Uploading a ZIP File

Uploading a JAR File

Uploading a ZIP File from OBS

Node.js

Supported

Supported

Not supported

Supported

Python

Supported

Supported

Not supported

Supported

Java

Not supported

Supported

Supported

Supported

Go

Not supported

Supported

Not supported

Supported

C#

Not supported

Supported

Not supported

Supported

PHP

Supported

Supported

Not supported

Supported

Custom runtime

Supported

Supported

Not supported

Supported

Cangjie

Not supported

Supported

Not supported

Supported

Notice

If the code to be uploaded contains sensitive information (such as account passwords), encrypt the sensitive information to prevent leakage.

Node.js

Editing Code Inline

FunctionGraph provides an SDK for editing code in Node.js. If your custom code uses only the SDK library, you can edit code using the inline editor on the FunctionGraph console. After you edit code inline and upload it to FunctionGraph, the console compresses your code and the related configurations into a deployment package that FunctionGraph can run.

Uploading a Deployment Package

If your code uses other resources, such as a graphic library for image processing, you need to create a deployment package, and then upload the package to the FunctionGraph console. You can upload a Node.js deployment package in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

Python

Editing Code Inline

FunctionGraph provides an SDK for editing code in Python. If your custom code uses only the SDK library, you can edit code using the inline editor on the FunctionGraph console. After you edit code inline and upload it to FunctionGraph, the console compresses your code and the related configurations into a deployment package that FunctionGraph can run.

Uploading a Deployment Package

If your code uses other resources, such as a graphic library for image processing, you need to create a deployment package, and then upload the package to the FunctionGraph console. You can upload a Python deployment package in two ways.

Notice
  • When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.
  • When you write code in Python, do not name your 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.
  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

Java

Java is a compiled language, which does not support editing code inline. You can only upload a local deployment package, which can be a ZIP or JAR file.

Uploading a JAR File

  • If your function does not use any dependencies, directly upload a JAR file.
  • If your function uses dependencies, upload them to an OBS bucket, set them during function creation, and upload the JAR file.

Uploading a ZIP File

If your function uses third-party dependencies, compress the dependencies and the function JAR file into a ZIP file, and then upload the ZIP file.

You can upload a Java deployment package in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

Go

Uploading a Deployment Package

You can only upload a Go deployment package in ZIP format, and you can upload it in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

C#

Uploading a Deployment Package

You can only upload a C# deployment package in ZIP format, and you can upload it in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

PHP

Editing Code Inline

FunctionGraph provides an SDK for editing code in PHP. If your custom code uses only the SDK library, you can edit code using the inline editor on the FunctionGraph console. After you edit code inline and upload it to FunctionGraph, the console compresses your code and the related configurations into a deployment package that FunctionGraph can run.

Uploading a Deployment Package

If your code uses other resources, such as a graphic library for image processing, you need to create a deployment package, and then upload the package to the FunctionGraph console. You can upload a PHP deployment package in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

Custom Runtime

Editing Code Inline

After you edit code inline and upload it to FunctionGraph, the console compresses your code and the related configurations into a deployment package that FunctionGraph can run.

Uploading a Deployment Package

If your code uses other resources, such as a graphic library for image processing, you need to create a deployment package, and then upload the package to the FunctionGraph console. You can upload a deployment package for a custom runtime in two ways.

Notice

When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.

  • Directly uploading a local deployment package

    After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 50 MB, upload the package using an OBS bucket.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

    After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

    For details about function resource restrictions, see Quotas and Usage Restrictions.

Cangjie

Cangjie is a statically typed language that does not allow online code editing. You can only upload code through a ZIP file.

Notice
  • When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.
  • The size of the decompressed source code cannot exceed 1.5 GB.
  • Directly uploading a local deployment package

After creating a ZIP deployment package, upload it to the FunctionGraph console. If the package size exceeds 40 MB, upload the package from OBS.

For details about function resource restrictions, see Quotas and Usage Restrictions.

  • Uploading a deployment package using an OBS bucket

After creating a ZIP deployment package, upload it to an OBS bucket in the same region as your FunctionGraph, and then paste the link URL of the OBS bucket into the function. The maximum size of the ZIP file that can be uploaded to OBS is 300 MB.

For details about function resource restrictions, see Quotas and Usage Restrictions.