This document describes how to use Serverless Cloud Framework to quickly create, configure, and deploy an Serverless Cloud Function (SCF) application on Tencent Cloud.
You have signed up for a Tencent Cloud account as instructed in Signing Up.
In an empty folder directory, run the following command:
Next, initialize the project as prompted. Select the
scf-starter template for the application and select the runtime you want to use (Node.js is used as an example here):
serverless-cloud-framework: No Serverless project is detected. Do you want to create a project? Yes
serverless-cloud-framework: Select the Serverless application you want to create: scf-starter - quickly deploys an SCF function
react-starter - quickly deploys a React.js application
restful-api - quickly deploys a RESTful API to use Python + API Gateway
❯ scf-starter - quickly deploys an SCF function
vue-starter - quickly deploys a basic Vue.js application
website-starter - quickly deploys a static website
eggjs-starter - quickly deploys a basic Egg.js application
express-starter - quickly deploys a basic Express.js application
serverless-cloud-framework: Select the runtime of the application: scf-nodejs - quickly deploys an SCF function in Node.js
scf-golang - quickly deploys an SCF function in Go
❯ scf-nodejs - quickly deploys an SCF function in Node.js
scf-php - quickly deploys an SCF function in PHP
scf-python - quickly deploys an SCF function in Python
serverless-cloud-framework: Enter the project name: demo
serverless-cloud-framework: Installing the scf-nodejs application...
scf-nodejs › Created
The demo project has been successfully created!
Click Deploy Now to quickly deploy the initialized project to the SCF console:
serverless-cloud-framework: Do you want to deploy the project in the cloud now? Yes
Click the link below to log in:
Logged in successfully!
Action: "deploy" - Stage: "dev" - App: "scfApp" - Name: "scf-nodejs"
description: This is a function in scfApp application
SCF console: https://serverless.cloud.tencent.com/apps/scfApp/scf-nodejs/dev
184s »scf-nodejs» Execution succeeded.
After deployment, complete the remote invocation of the function by running the following command:
scf invoke --inputs function=helloworld
scf is short for
Viewing the Deployment Information
To view the application deployment statuses and resources again, go to the directory that is successfully deployed and run the following command:
Viewing the directory structure
In the directory of the initialized project, you can see the most basic structure of a serverless function project:
serverless.yml configuration file implements the quick configuration of the basic function information. All the configuration items supported by the SCF console can be configured in the
.yml file. For more information, see SCF Configuration Information.
index.js is the entry function of the project, which is the
helloworld template here.
.env file stores user login authentication information. You can also configure other environment variables in it.
In the local project directory, you can modify the function template and configuration file and then redeploy the project by running the following command:
To view the detailed information during removal, you can add the
After the deployment is completed, Serverless Cloud Framework allows you to run different commands to implement capabilities such as continuous development and grayscale release for the project. You can also use this component in conjunction with other components to manage the deployment of multi-component applications.
Question 1: What should I do if the wizard does not pop up by default after I enter
Solution: Add the
SERVERLESS_PLATFORM_VENDOR=tencent configuration to the
Question 2: What should I do if the deployment is very slow in an overseas network after I enter
sls deploy ?
Solution: Add the
GLOBAL_ACCELERATOR_NA=true configuration to the
.env file to accelerate the overseas network.
Question 3: What should I do if a network error occurs during deployment after I enter
scf deploy ?
Solution: Add the following proxy configurations to the