Serverless Devs是一个开源开放的Serverless开发者平台,通过该平台您可以快速地开发、创建、测试和部署项目,实现项目的全生命周期管理。本文以部署运行环境是Node.js 12的函数为例,介绍如何使用Serverless Devs下载对应的函数计算应用模板,然后快速开发部署函数应用。
背景信息
前提条件
方式一:使用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