All Products
Search
Document Center

Function Compute:Sample code

Last Updated:Sep 19, 2024

Function Compute provides a variety of sample code that can be directly used to create and configure functions. This topic provides a collection of sample code for various use cases.

Usage notes

For detailed information about how to use the sample code in this topic, see the readme.md files in the corresponding code libraries.

Hello World

Standard runtime

Custom runtime

Custom Container runtime

HTTP functions

Event functions

WebSocket functions

N/A

Custom frameworks

N/A

N/A

Access other Alibaba Cloud services

Node.js

Python

PHP

Go

Java

Access a MySQL database (Node.js 14).

Access a MySQL database (Python 3)

Access a MySQL database (PHP 7.2)

Access a MySQL database (Go 1)

Access a MySQL database (Java 11)

Access a MongoDB database (Node.js 14)

Access a MongoDB database (Python 3)

Access a MongoDB database (PHP 7.2)

Access a MongoDB database (Go 1)

Access a MongoDB database (Java 11)

Access Tablestore (Node.js 14)

Access Tablestore (Python 3)

Access Tablestore (PHP 7.2)

Access Tablestore (Go 1)

Access Tablestore (Java 11)

None

Access MaxCompute (Python 3)

None

None

Access MaxCompute (Java 11)

Deliver messages to ApsaraMQ for Kafka (Node.js 14)

Deliver messages to ApsaraMQ for Kafka (Python 3)

None

Deliver messages to ApsaraMQ for Kafka (Go 1)

Deliver messages to ApsaraMQ for Kafka (Java 11)

Deliver messages to queues in Simple Message Queue (formerly MNS) (Node.js 14)

Deliver messages to queues in Simple Message Queue (formerly MNS) (Python 3)

Deliver messages to queues in Simple Message Queue (formerly MNS) (PHP 7.2)

Deliver messages to queues in Simple Message Queue (formerly MNS) (Go 1)

Deliver messages to queues in Simple Message Queue (formerly MNS) (Java 11)

Deliver messages to topics in Simple Message Queue (formerly MNS) (Node.js 14)

Deliver messages to topics in Simple Message Queue (formerly MNS) (Python 3)

Deliver messages to topics in Simple Message Queue (formerly MNS) (PHP 7.2)

Deliver messages to topics in Simple Message Queue (formerly MNS) (Go 1)

Deliver messages to topics in Simple Message Queue (formerly MNS) (Java 11)

Deliver messages to ApsaraMQ for RocketMQ (Node.js 14)

Deliver messages to ApsaraMQ for RocketMQ (Python 3)

None

Deliver messages to ApsaraMQ for RocketMQ (Go 1)

Deliver messages to ApsaraMQ for RocketMQ (Java 11)

Trigger a function by using an Alibaba Cloud service

Node.js

Python

PHP

Go

Java

Trigger a function by using a time trigger (Node.js 14)

Trigger a function by using a time trigger (Python 3)

None

Trigger a function by using a time trigger (Go 1)

Trigger a function by using a time trigger (Java 11)

Trigger a function by using Simple Log Service (Node.js 14)

Trigger a function by using Simple Log Service (Python 3)

None

Trigger a function by using Simple Log Service (Go 1)

Trigger a function by using Simple Log Service (Java 11)

Trigger a function by using Object Storage Service (OSS) (Node.js 14)

Trigger a function by using OSS (Python 3)

Access OSS (PHP 7.2)

Trigger a function by using OSS (Go 1)

Trigger a function by using OSS (Java 11)

Trigger a function by using Alibaba Cloud CDN (Node.js 14)

Trigger a function by using Alibaba Cloud CDN (Python 3)

Trigger a function by using Alibaba Cloud CDN (PHP 7.2)

Trigger a function by using Alibaba Cloud CDN (Go 1)

Trigger a function by using Alibaba Cloud CDN (Java 11)

Trigger a function by using ApsaraMQ for Kafka (Node.js 14)

Trigger a function by using ApsaraMQ for Kafka (Python 3)

None

Trigger a function by using ApsaraMQ for Kafka (Go 1)

Trigger a function by using ApsaraMQ for Kafka (Java 11)

Trigger a function by using queues in Simple Message Queue (formerly MNS) (Node.js 14)

Trigger a function by using queues in Simple Message Queue (formerly MNS) (Python 3)

Trigger a function by using queues in Simple Message Queue (formerly MNS) (PHP 7.2)

Trigger a function by using queues in Simple Message Queue (formerly MNS) (Go 1)

Trigger a function by using queues in Simple Message Queue (formerly MNS) (Java 11)

Trigger a function by using topics in Simple Message Queue (formerly MNS) (Node.js 14)

Trigger a function by using topics in Simple Message Queue (formerly MNS) (Python 3)

Trigger a function by using topics in Simple Message Queue (formerly MNS) (PHP 7.2)

Trigger a function by using topics in Simple Message Queue (formerly MNS) (Go 1)

Trigger a function by using topics in Simple Message Queue (formerly MNS) (Java 11)

Web applications

Node.js

Python

PHP

Go

Java

Others

Express [custom]

Flask [python3]

Think PHP [custom]

Gin [custom]

SpringBoot [custom]

Hugo [custom]

Egg [custom]

Tornado [custom]

Laravel [custom]

None

None

None

Next.js [custom]

None

None

None

None

None

None

Web.py [python3]

None

None

None

None

Hapi [custom]

Django [python3]

None

None

None

None

Koa [custom]

FastAPI [custom]

None

None

None

None

Nest [node.js12]

None

None

None

None

None

None

None

Whatsns [custom]

None

None

None

Think.js [node.js12]

None

None

None

None

None

None

None

Kodbox [custom]

None

None

None

Static website applications

AI scenarios

Audio and video processing

Other regions