新手入门 新建 Serverless Devs 项目 创建一个空文件夹,在该文件夹下创建 s.yaml 文件、code 目录,然后在 code 目录下 创建 index.py 文件。文件目录结构如下: index.py 文件为函数代码,文件内容如下: python def handler(event, context): return 'hello world' Serverless Devs 工具默认使用 s.yaml 文件描述部署资源的元信息,其内容如下: plaintext edition: 3.0.0 name: hellodevsapp access: default vars: region: "bb9fdb42056f11eda1610242ac110002" resources: myfunc: component: faascf 组件,提供具体的业务能力。faascf 组件提供了对天翼云Serverless函数的管理能力 props: region: ${vars.region} 部署的资源池,天翼云华东1资源池为 bb9fdb42056f11eda1610242ac110002 functionName: helloworld 函数名称 code: ./code 函数代码目录 createType: 1 函数类型:标准函数(1)、自定义函数(2)、容器函数(3) runtime: 函数运行配置 handleType: event 处理事件请求(event)、处理HTTP请求(http) handler: index.handler 请求处理程序 runtime: python3.10 运行环境 executeTimeout: 64 执行超时时间 instanceConcurrency: 1 实例并发度 container: 运行容器配置 memorySize: 512 内存规格,单位:MB cpu: 0.5 vCPU规格,单位vCPU diskSize: 512 临时硬盘大小,单位:MB timeZone: UTC 时区,例如:UTC, Asia/Shanghai 部署函数 进入到 s.yaml 文件所在的路径,执行如下命令进行部署函数: shell s deploy 如果部署函数成功,将会显示如下输出: plaintext functionId: 39061695070521915 code: ossBucketName: ossObjectName: function/ snapshotOssObjectName: zipFile: container: image: faas/python3.10runtime:v1.3.1 timeZone: UTC memorySize: 512 cpu: 0.5 diskSize: 512 runCommand: Li9ib290c3RyYXAuc2g listenPort: 8080 codeDirPath: /code logLevel: sysLogLevel: INFO maxScale: null minScale: null fastStart: 0 functionName: helloworld ...