You need to enable JavaScript to run this app.
文档中心
函数服务

函数服务

复制全文
下载 pdf
快速入门
基于模板创建应用
复制全文
下载 pdf
基于模板创建应用
本文介绍如何通过函数服务 CLI 中的应用模板快速创建应用。​
前提条件​
已完 CLI 安装和其他准备工作,详情参见 准备工作 和 CLI 安装。​
操作步骤​
  1. 登录函数服务 CLI。​
说明​
首次使用时,会引导您输入 AK/SK 完成鉴权。​
​
vefaas login​
> You can obtain credentials from Volcengine IAM​
? Access Key ID (AK): ********************************************​
? Secret Access Key (SK): ************************************************************​
> Credentials have been saved to ~/.vefaas/auth.json​
Congratulations! You are now signed in.​
To deploy something, run `vefaas`.​
​
  1. 选择模板创建项目。选择模板后,可配置模板拉取的目录。​
​
vefaas init​
? Template list (Type to filter, arrow keys to navigate, Enter to confirm, Ctrl+C to cancel.) ›​
> FastAPI - 快速创建部署 FastAPI 框架,快速且高效的 Web 框架,用于构建基于 Python 的 API。​
Vitepress - 静态文档生成器 (SSG),专为构建快速、以内容为中心的站点而设计​
Express - 基于 Native 运行时,内置 Node.js 和 Express.js 框架,为用户快速部署一个可通过公网访问的 Web 应用​
​
  1. 登录到模板拉取的文件夹。​
​
> Selected template: FastAPI​
? Detected directory 'fastapi' already exists. Initialize the app into a new directory? yes​
? Enter a new directory name fastapi-new​
​
✨ fastapi-new project has been created with the FastAPI template. Next steps:​
> cd fastapi-new​
> Run `vefaas` to deploy.​
​
  1. 基于模板部署应用。​
​
vefaas​
> No linked application found. Launching link flow...​
? Set up and deploy "~/codebase/faas/playground/fastapi-new"? yes​
? Link to an existing application? no​
? Enter application name fastapi-new-1229​
> You need to select an API Gateway instance to bind your new application.​
✔ Select a running API Gateway (Type to filter, arrow keys to navigate, Enter to confirm, Ctrl+C to cancel.) › faas-application-serverless-gateway​
> Auto-detected or default application settings:​
> - Build Command: ./build.sh​
> - Output Directory: ./​
> - Start Command: ./run.sh​
> - Port: 8000​
> - Runtime: native-python3.12/v1​
? Would you like to modify these settings? no​
> Successfully created and linked application "fastapi-new-1229". Updated config in .vefaas/config.json​
> Linked application: "fastapi-new-1229". Updated config in .vefaas/config.json​
> Package created: packaged "~/codebase/faas/playground/fastapi-new", size 0.01MB​
> Console: Manage this application (https://console.volcengine.com/vefaas/region:vefaas+cn-beijing/application/detail/******)​
> Access URL (available now): https://**********.apigateway-cn-beijing.volceapi.com/​
> Deploy succeeded.​
​
  1. 查看应用的访问地址。部署成功后,通过以下代码查看应用的访问地址。​
​
> vefaas domains​
> Access URL (available after deployment): https://*********.apigateway-cn-beijing.volceapi.com/​
> Access URL (available after deployment): https://*********.apigateway-cn-beijing-inner.volceapi.com/​
​
后续操作​
基于模板开发应用​
  • Node.js 运行时​
  1. 本地环境初始化:执行 npm i 安装项目依赖。​
  1. 启动本地开发:执行 npm run start 启动本地开发服务。​
  1. 函数更新部署:需更新函数时,执行 vefaas deploy 完成部署。​
  • Python 运行时​
  1. 安装依赖包:执行 pip i -r requirements.txt 安装项目依赖。​
  1. 启动本地开发:执行 python main.py 启动本地开发服务。​
  1. 函数更新部署:需更新函数时,执行 vefaas deploy 完成部署。​
​
> vefaas​
> Linked application: "fastapi-new-1229". Updated config in .vefaas/config.json​
> Package created: packaged "~/codebase/faas/playground/fastapi-new", size 0.01MB​
> Deploy succeeded.​
​
​
​
最近更新时间:2026.02.13 16:52:42
这个页面对您有帮助吗?
有用
有用
无用
无用