tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary

Deploying Functions

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-10-22 15:42:55

Deployment Through Console

A deployment package is a zip collection of all the code and dependencies that SCF runs, which should be specified during function creation. You can create a deployment package in your local environment and upload it to SCF or write the code directly in the SCF Console which will create and upload the deployment package for you. Please use the following criteria to determine whether you can use the console to create a deployment package:
Simple scenario: if your custom code only needs to use standard libraries or SDK libraries such as COS and SCF libraries provided by Tencent Cloud, and there is only one code file, you can use the online editor in the SCF Console which automatically compresses the code and associated configuration information into an operable deployment package.
Advanced scenario: if your code requires additional resources (such as a graphics library for image processing, web framework for web programming, or database connection library for executing database commands), you need to first create a function deployment package in your local environment and then upload it to the console.

Packaging requirements

Zip format

The code package submitted directly to the SCF platform or submitted by uploading to COS and then imported into SCF must be in zip format. 7-Zip can be used on Windows and zip command line tools can be used on Linux for compression or decompression.

Packaging method

When packaging, you need to package the code files but not the entire directory of the code; after packaging is completed, the entry function file must be in the root directory of the package.
When packaging on Windows, you can enter the function code directory, select all files, right-click and select "Send to > Compressed (zipped) folder" to create the deployment package. If a tool such as 7-Zip is used to unzip and browse the package, the entry function and other libraries should be included in the package.
When packaging on Linux, you can enter the function code directory, run the zip command, and specify the source files as all files in the code directory to generate the deployment package, such as zip /home/scf_code.zip * -r.

Sample deployment package

The following sample illustrates the steps to create a deployment package in a local environment.
Note:
Normally, locally installed dependent libraries work well on the SCF platform. In rare cases, the binary files installed may have compatibility problems. If this happens, please contact us.
For the Python programming language in the sample, libraries and dependencies will be installed locally using the pip tool. Please make sure that you have already installed Python and pip locally.

Python deployment package

Creating Python deployment package on Linux

1. Create a directory:
mkdir /data/my-first-scf
2. Save all the Python source files (.py files) of the function into this directory.
3. Install all dependencies to this directory using pip:
pip install <module-name> -t /data/my-first-scf
For example, the following command installs the Pillow library in the my-first-scf directory:
pip install Pillow -t /data/my-first-scf
4. Compress everything in the my-first-scf directory. Please note that you need to compress the content of the directory but not the directory itself:
cd /data/my-first-scf && zip my_first_scf.zip * -r
Note:
For libraries with compilation process, we recommend you perform packaging on CentOS 7 to maintain consistency with the SCF runtime environment.
If there are requirements for other software, compilation environment, or development libraries during installation or compilation, please solve the compilation and installation problems as instructed.

Creating Python deployment package on Windows

We recommend you package the dependent packages and codes that have already been successfully executed on Linux into a zip package as the execution code of the function. For more information, please see Code Practice - Getting Images in COS and Creating Thumbnails.
In Windows, you can use the pip install <module-name> -t <code-store-path> command to install Python libraries. But for packages that need to be compiled or have static or dynamic libraries, libraries compiled and generated on Windows cannot be invoked in SCF runtime environment (CentOS 7), so only libraries completely implemented in Python can be installed on Windows.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백