SCF CLI Tencent and so on function (Serverless Cloud Function, SCF) products command-line tool must have a lot of small partners already know, or after a trial. As a developer tool that can improve efficiency, Tencent cloud Serverless team has been optimized to work on the SCF CLI,
this article will introduce you to the new SCF CLI increase of interesting features !
Introduction
A, Deploy function optimization
1: Deploy can select the default COS
Just set the time, using-cos will be provided, of course, also be scf configure set --using-cos y directly set:
Once selected, you can in the next deployment, the default upload code to your cos, faster deployment:
Even if you set cos, when a particular Deploy, cos do not want to use, you can choose not to deploy by cos increase --without-cos:
COS also want to customize can: - cos-bucket:
(In the absence of this cos, so upload failed)
In everyday use, there may be deployment of the same piece of code.
For example, I deployed the code A, B and deployment of code. After that, I want to re-deploy the code A, according to the traditional method is to upload A code again, but if Package is relatively large, it is more uncomfortable. The new version of the CLI through Package testing, 130M for the first time deployed using 25s, a second deployment of the same file, only 2s.
Attached: COS-related billing Links
Free credit:
https://cloud.tencent.com/document/product/436/6240
-
Billing Summary:
https://cloud.tencent.com/document/product/436/16871
-
Accounting method :
https://cloud.tencent.com/document/product/436/36522
-
Product Pricing
https://cloud.tencent.com/document/product/436/6239
2: Deploy version history
Code deployment, if problems arise, the need to restore the version history. The new version supports the deployment of SCF CLI version of history, after you use the using-cos, version history can be deployed by the parameters --history deploy:
Select a historical version, you can directly implement document rollback:
3: Packaging optimization function
All files are packaged under the old version will SCF CLI user directory, the new SCFCLI in this respect also made a key optimization, you can specify the ZIP directly, specify a file, and packaged by default when removing the .git and other hidden directory, and after deploy before deleting the default package information.
Yaml file can be:
Second, the new Delete function
Older SCF CLI does not support the Delete function in the new version, you can comfortably use:
Just enter scf delete --help you can see the use of methods and parameters described in Oh!
Third, the new List function
In the past, if you want to view the contents of the cloud function, or what I deploy function, is the need to go to the console area one by one, one by one namespace view. Now without cumbersome, can be realized by List command:
The same can view all usage by the SCF --help: scf list --help
Fourth, help optimize document
Many of the above description, so that we are using the --help to view the help, then in the new version - which has a big help to optimize it - global optimization help document, you can view the help in any --help command :
In the instruction pages can be an example to look at:
Each main instruction, instructions will be described using examples and, while the specification is described parameters.
Five, API Gateway section
Existing SCF CLI always need when using the new API Gateway, you do not want the new, you need to annotate the configuration file or use the --skip-event, which makes many users a headache. The new SCF CLI API Gateway in part increased ServiceId fields:
With this field, when we used can be selected directly bind the existing gateway. After the new gateway, the system will prompt:
The gateway can be avoided next time you create a fill in the corresponding ID. Such a simple field increases, the little fellows brought two excellent experience:
1: can bind existing API Gateway does not require new
2: the gateway can ensure that the existing form, not every new
Sixth, to optimize output
It should be noted that small-minded partners, and this update, UI change is very large. When we use cloud functions, different expression will display in different colors:
Meanwhile, after Deploy, we do not open the page to see the cloud function information, but directly through the console see:
experiment
Hello world
To Hello World, for example, by helping to create the command View init:
scf init --help
According to an example of creating Python language hello world:
scf init --runtime python3.6
Project editor cd hello_world: Follow the prompts
Modify the code and gateway configuration:
Gateway to use here, I do not want to create a new gateway, but want to use already have an API Gateway:
Fill serviceeId:
Then save and exit, Deploy:
Once deployed, the output function information:
Open API gateway subDomain:
Deployment success!
View the list of functions
Just enter scf list
Delete function
Only you need to enter the function-related information to be deleted:
scf delete --name hello_world --region ap-shanghai --namespace default
This article describes the command-line tools and practices with regard to the appointment of a deputy come to an end.
More features waiting for you to dig their own small partners Oh!
Recommended reading: