Serverless Devsは、サーバーレスアプリケーション開発者向けのオープンソースプラットフォームです。 Serverless Devsを使用して、プロジェクトの開発、作成、テスト、デプロイを行い、プロジェクトのライフサイクルを効率的に管理できます。 このトピックでは、Serverless Devsを使用してFunction Computeアプリケーションテンプレートをダウンロードし、そのテンプレートを使用して関数アプリケーションを開発およびデプロイする方法について説明します。 このトピックでは、Node.js 12の関数を使用します。
このタスクについて
作業の前に
方法1: sコマンドを使用してリソースを管理する
次のコマンドを実行して、プロジェクトを初期化します。
s
コマンド出力に基づいてプロジェクトを初期化します。 次の出力が返されます。
No Serverless-Devs project is currently detected. Do you want to create a new project? Yes//在项目文件内未检测到Serverless-Devs项目。选择是否创建一个项目。
Serverless Awesome: https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/zh/awesome.md
Hello Serverless for Cloud Vendors Alibaba Cloud Serverless//选择目标云厂商,本示例以阿里云为例。
Hello, serverlesser. Which template do you like? Quick start [Deploy a Hello World function to FaaS]//选择您需要创建的模板。本示例以快速部署运行环境为Node.js 12的事件函数为例。
Which template do you like? [Event] Node.js 12
Create application command: [s init devsapp/start-fc-event-nodejs12]
Please input your project name (init dir) start-fc-event-nodejs12//Serverless Devs默认为您生成一个项目名称,您也可以自定义该名称。
file decompression completed
____ _ _ ___ _ _ _ _____ ____
/ _ \/ \ / \\ \/// \ /\/ \ /| / // _\
| / \|| | | | \ / | | ||| |\ || | __\| /
| |-||| |_/\| | / / | \_/|| | \|| | | | \__
\_/ \|\____/\_//_/ \____/\_/ \| \_/ \____/
please select credential alias default//选择您在配置Serverless Devs时设置的别名。
Welcome to the Aliyun FC start application
This application requires to open these services:
FC : https://fc.console.aliyun.com/
* 项目初始化完成,您可以直接进入项目目录下,并使用s deploy进行项目部署。
Thanks for using Serverless-Devs
You could [cd /test/start-fc-event-nodejs12] and enjoy your serverless journey!
If you need help for this example, you can use [s -h] after you enter folder.
Document Star:https://github.com/Serverless-Devs/Serverless-Devs
Do you want to deploy the project immediately? Yes//选择是否部署项目,本示例以选择部署项目为例。
......
helloworld:
region: cn-hangzhou
service:
name: hello-world-service
function:
name: event-nodejs12
runtime: nodejs12
handler: index.handler
memorySize: 128
timeout: 60