By Tan Hehe (nicknamed Xiaomo)
First, let's take a look at the definitions of some key terms used in this article:
Function Compute: is an event-driven service that allows users to write and upload code without having to manage server health or consider other factors. After Function Compute allocates required computing resources, it elastically runs your code. The fees of using these resources are billed based on their actual consumption. For more information about Function Compute, visit the official product page.
Fun: is a developer tool for serverless applications. It helps you manage resources such as Function Compute, API Gateway, and Log Service. You can use Fun to develop, build, and deploy resources by describing them in the template.yml file. For more information about Fun, click here.
ROS (Resource Orchestration Service): helps you simplify the management of cloud computing resources. By following the template specifications defined by ROS, you can define the collection of required cloud computing resources and their dependencies. ROS automatically creates and configures all resources to implement automated deployment and O&M. For more documents on ROS, visit the official product page.
Note: The techniques described in this article are only applicable to Fun 3.0.8 or later.
First, follow the Fun installation document to install Fun on your local computer.
After the installation is completed, run fun --version
to check that Fun has been successfully installed.
Run fun init
to initialize a project.
fun init -n SpringBootDemo
After the initialization is completed, a directory named SpringBootDemo is added to the current directory structure.
The result is as follows:
Run fun build
to compile and build the project:
fun build
The result is as follows:
Note: You can skip this step if you do not need to run the project locally.
Run fun local start
to run the FUN function locally.
Run the following command.
fun local start demo-springboot
The result is as follows:
Note: You can skip this step if you do not need to debug the project locally.
Run fun local start
to perform local single-step debugging on the function.
Both VSCode and IDEA can run and debug Function Compute. For more information, see the VSCode plug-in serverless-vscode and the IDEA plug-in Cloud Toolkit.
Considering our audience, we will not use plug-ins for debugging here.
The result is as follows:
Run fun deploy --use-ros
to deploy the project through ROS.
fun package --oss-bucket fun-local-test
fun deploy --use-ros --stack-name staging
Here, the --oss-bucket
name indicates the name of an OSS bucket that you can read and write.
--stack-name
indicates the environment where the project is deployed. You can create multiple development environments by setting different names for them, such as test, staging, and prod.
The following example shows how to quickly create a staging environment. The result is as follows:
After the test is completed, you can log on to the ROS console to delete the staging resource stack just created with a single click. After the deletion, all resources contained in this stack will also be deleted.
A Proof of the Auto Scaling Capabilities of Function Compute
99 posts | 7 followers
FollowAlibaba Clouder - January 20, 2021
Alibaba Cloud Native - March 6, 2024
Alibaba Cloud Serverless - December 17, 2020
Alibaba Cloud Native Community - September 12, 2023
Alibaba Cloud Community - March 15, 2023
Alibaba Developer - May 21, 2021
99 posts | 7 followers
FollowVisualization, O&M-free orchestration, and Coordination of Stateful Application Scenarios
Learn MoreSimplify the Operations and Management (O&M) of your computing resources
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreCloudOps Orchestration Service is an automated operations and maintenance (O&M) service provided by Alibaba Cloud.
Learn MoreMore Posts by Alibaba Cloud Serverless