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

Trigger Overview

PDF
フォーカスモード
フォントサイズ
最終更新日: 2024-12-02 19:58:17
SCF currently supports two triggering modes: event-triggered and HTTP request-triggered.

Event-Triggered

Event-Triggered is a typical serverless execution mode. Its core components are SCF functions and event sources, where an event source is a Tencent Cloud service or user-defined code that publishes an event, an SCF function is the handler of the event, and a function trigger is a set of correspondences between functions and event sources. For example, in the following scenarios:
Image/Video processing: the application crops the images uploaded by users into an appropriate size, stores the images in COS, creates thumbnails of each image, and displays them on the user page. In this scenario, you need to select COS as the event source and publish the event to the SCF function when the file is created. The event data provides all the information about the bucket and the file.
Data processing: the data collected during the day (such as clickstreams) is analyzed with a report generated at 00:00. In this scenario, you need to select a timer as the event source to publish an event to the SCF function at a specific time.
Custom application: the first image is invoked in your application to handle the SCF function as a module of the application. In this scenario, you need to call the Invoke API in the application to publish an event.
These event sources can be any of the following:
Internal event sources: these are preconfigured Tencent Cloud services that can be used with SCF. If you configure one of these event sources as a function trigger, the function will be invoked automatically when an event occurs. The relationship between the event source and the function (i.e., event source mapping) will be maintained on the event source side.
Custom applications: you can let custom applications publish events and invoke SCF functions.

Sample 1. COS publishes an event and invokes a function

You can configure the event source mapping for COS to determine what behaviors of COS will trigger an SCF function (such as object PUT or DELETE). The COS event source mapping is stored in COS and uses the bucket notification feature to direct COS to invoke the function when an event of a particular type occurs:
A COS trigger is created.
The user creates/deletes an object in the bucket.
COS detects an object creation/deletion event.
COS automatically invokes a function. It will be determined which function should be invoked based on the event source mapping stored in the COS configuration. The bucket and object information will be passed to the function as event data.

Sample 2. A timer publishes a time and invokes a function

The event source mapping of the timer is saved in the SCF function configuration to determine when the function should be automatically triggered:
A timer trigger is created.
The timer automatically invokes the function at the configured time.

Sample 3. A custom application invokes a function

If you need to invoke an SCF function in a custom application, you do not need to configure a function trigger or set up an event source mapping in this case; instead, you can use the Invoke API as the event source.
The custom application uses the Invoke API to invoke the function and pass in the event data.
The function receives the triggering request and is executed.
If sync invocation is used, the function will return the result to the application.
Note:
In this example, since the custom application and the function are produced by the same user, the user credentials (APPID, SecretId, and SecretKey) can be specified.

Notes

1. The current trigger-related restrictions for a single function can be viewed in Quota Limits.
2. There are specific restrictions on event source mappings due to the limitations of different Tencent Cloud services. For example, for a COS trigger, the same event (such as file upload) in the same COS bucket cannot trigger multiple different functions.

HTTP Request-Triggered

HTTP request-triggered is a special trigger method supported by SCF web functions. A native HTTP request can be directly passed through to the function environment through API Gateway to trigger the execution and processing of the function. It is suitable for the development of web service scenarios. For detailed usage, please see Function Overview.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック