What Are the Rules for Packaging a Function Project?

In addition to inline code editing, you can create a function by uploading a ZIP or JAR file, or uploading a ZIP file from OBS. For details, see Packaging Rules and Example ZIP Project Packages.

Packaging Rules

In addition to inline code editing, you can create a function by uploading a local ZIP file or JAR file, or uploading a ZIP file from Object Storage Service (OBS). Table 1 describes the rules for packaging a function project.

Table 1 Function project packaging rules

Runtime

JAR File

ZIP File

ZIP File on OBS

Node.js

Not supported.

  • If the function project files are saved under the ~/Code/ directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.
  • If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.

Compress project files into a ZIP file and upload it to an OBS bucket.

PHP

Not supported.

  • If the function project files are saved under the ~/Code/ directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.
  • If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.

Compress project files into a ZIP file and upload it to an OBS bucket.

Python 2.7

Not supported.

  • If the function project files are saved under the ~/Code/ directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.
  • If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.

Compress project files into a ZIP file and upload it to an OBS bucket.

Python 3.6

Not supported.

  • If the function project files are saved under the ~/Code/ directory, select and package all files under this directory to ensure that the function handler is under the root directory after the ZIP file is decompressed.
  • If the function project uses third-party dependencies, package the dependencies into a ZIP file, and import the ZIP file on the function code page. Alternatively, package the third-party dependencies and the function project files together.

Compress project files into a ZIP file and upload it to an OBS bucket.

Java 8

If the function does not reference third-party components, compile only the function project files into a JAR file.

If the function references third-party components, compile the function project files into a JAR file, and compress all third-party components and the function JAR file into a ZIP file.

Compress project files into a ZIP file and upload it to an OBS bucket.

Go 1.x

Not supported.

Zip the compiled file and ensure that the name of the binary file is consistent with that of the handler. For example, if the name of the binary file is Handler, set the name of the handler to Handler.

Compress project files into a ZIP file and upload it to an OBS bucket.

C#

Not supported.

Compress project files into a ZIP file. The ZIP file must contain the following files: Project_name.deps.json, Project_name.dll, Project_name.runtimeconfig.json, Project_name.pdb, and HC.Serverless.Function.Common.dll.

Compress project files into a ZIP file and upload it to an OBS bucket.

Custom

Not supported.

Compress project files into a ZIP file. The ZIP file must contain a bootstrap file.

Compress project files into a ZIP file and upload it to an OBS bucket.

Example ZIP Project Packages