Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ FunctionGraph/ User Guide/ Building Functions/ Creating a Deployment Package

Creating a Deployment Package

Updated on 2024-11-12 GMT+08:00

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.

NOTE:
  • After programming, simply package your code into a ZIP file (Java, Node.js, Python, and Go) or JAR file (Java), and upload the file to FunctionGraph for execution.
  • When creating a ZIP file, place the handler file under the root directory to ensure that your code can run normally after being decompressed.
  • If you edit code in Go, zip the compiled file, and 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.
  • Java is a compiled language, which does not support editing code inline. If your function does not use any third-party dependencies, you can upload a function JAR 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.

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

NOTICE:

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

Table 2 Code entry modes

Code Entry Mode

Description

Edit code inline

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 edit the code on the Code tab of the function details page.

  • File: Create files and folders, save changes, and close all files.
  • Edit: Undo/redo typing; cut, copy, and paste code; find and replace content.
  • Settings: Set the font size, auto formatting, and theme color.

Upload ZIP file

  1. On the Code tab of the function details page, choose Upload > Local ZIP.
  2. Click Select File and upload a local code package to FunctionGraph. The size of the ZIP file cannot exceed 40 MB. For a larger file, upload it through OBS.

Upload file from OBS

  1. On the Code tab of the function details page, choose Upload > OBS ZIP.
  2. Click Select File and upload a local code package to FunctionGraph.
NOTE:

If the size of the code you deploy is greater than 20 MB, the inline editor does not display the code, but you can still test your function.

Figure 1 Code not displayed in the editor

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, first 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.
  • The size of the decompressed source code cannot exceed 1.5 GB. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

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, first 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.
  • The size of the decompressed source code cannot exceed 1.5 GB. If the code is too large, contact the customer service.
  • 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 40 MB, upload the package from OBS.

    For details about function resource restrictions, see Notes and Constraints.

  • 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 Notes and Constraints.

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.
  • The size of the decompressed source code cannot exceed 1.5 GB. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

Go

Uploading a Deployment Package

You can only upload a Go deployment package in ZIP format. There are two ways to upload it.

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. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

C#

Uploading a Deployment Package

You can only upload a C# deployment package in ZIP format. There are two ways to upload it.

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. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

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, first 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.
  • The size of the decompressed source code cannot exceed 1.5 GB. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

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, first 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.
  • The size of the decompressed source code cannot exceed 1.5 GB. If the code is too large, contact the customer service.
  • 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 Notes and Constraints.

  • 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 Notes and Constraints.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback