This topic describes how to use Function Compute, including how to create a service, create a function, trigger a function, view execution logs, and view service monitoring data.
You must activate Function Compute before you can use related services. For more information, see Activate the Function Compute service.
The following figure shows the procedure for using Function Compute.
Create a function in the Function Compute console
You can use the Function Compute console to perform operations such as creating services, creating functions, and debugging functions. For more information, see Create a function in the Function Compute console.
Create a service
A service is the basic unit of resources in Function Compute. You can grant permissions, configure logging, and create functions for a service. For more information, see Manage services.
Create a function
A function is the basic unit for resource scheduling and running in Function Compute. A function specifies the logic of code. To create a function, you must write code by using a method specified by Function Compute and deploy the code to Function Compute as a function. A service in Function Compute is similar to a microservice in the software application architecture. When you build an application in Function Compute, you must abstract the business logic into microservices based on your business requirements and implement the microservices as services in Function Compute.
Test a function
- Trigger the function in the Function Compute console or by using Serverless Devs or SDKs. For more information, see the following topics:
- Configure a trigger in Function Compute and trigger the function by using events. For example, if you configure an Object Storage Service (OSS) trigger, the function is triggered when you create or delete an object in the corresponding OSS bucket. The uploaded objects can be automatically processed based on your business requirements. If you configure a Log Service trigger, the function is triggered when new logs are written to the corresponding Logstore to process the written logs based on your business requirements. A trigger is required to specify how the function is triggered by an event. For more information, see the following topics:
Use Serverless Devs to manage function resources
You can use Serverless Devs to build, debug, and deploy applications. For more information, see Manage function resources by using Serverless Devs.
Build an application
Initialize a project, configure the s.yaml file in the generated project directory, and then build an application in the project directory. After that, a .s file is generated in the current directory to store the outputs. You can use the file to debug and deploy applications on your local computer.
Debug an application
After an application is built, you can debug the application on your local computer based on the function type to check whether the function can run as expected.
Deploy an application
After you create and debug an application, you can deploy the application to Function Compute. After the function is deployed, the services and functions configured in the s.yaml file are deployed to Function Compute with one click.
For answers to commonly asked questions of Function Compute, see Overview.