This topic describes the concept of services in Function Compute.
A service is an object that helps you organize and manage resources in Function Compute. All functions of a service share the same configurations, such as service authorizations and logging configurations. One service can have multiple functions, and the functions can share the resources of service, such as Logstore and service role. A service provides the following benefits:
Helps you better organize your business components.
A service can represent an application. Functions used for the same application can be organized in one service.
Resources cannot be shared across services. That is, services are independent of each other.
Helps you manage resources in the form of services.
When you create a service, you must specify the following properties:
(Required) serviceName: Indicates the service name. This name must be unique under the same region and meet the following requirements:
- The name can consist of letters, numbers, underscores (_), and hyphens (-).
- The name must start with a letter or an underscore (_).
- The name is case-sensitive.
- The name must be between 1 to 128 characters in length.
(Optional) description: Displays the details of the specified service.
(Optional) role: Authorizes Function Compute to execute specific functions. For example:
- Authorize Function Compute to access Log Service, so that Function Compute can store and analyze the function execution logs.
- Authorize Function Compute to execute functions required for accessing other cloud resources.
- For more information about roles, see Introduction.
(Optional) logConfig: Sets the log project and Logstore for Log Service, and stores and analyzes function execution logs.
- If this property is not configured, function execution logs cannot be viewed. We recommend that you enable Log Service and set this property.
- For more information, see Function logs.
Note: In this case, Alibaba Cloud Log Service is used. Log Service charges fees for reserving certain resources, which means that even if no log is generated, you must pay for the service. For more information, see Billing methods.
(Optional) vpcConfig: Enables a function to access a specific VPC.
(Optional) internetAccess: Enables a function to access public networks when this property is set to true.
Except for the service name, other properties can be modified.
When you run fcli in shell mode, you can run the
mks/ups command to create or update a service, and run the
info command to view service properties.
In the following example, we create the my-service service, update the description and logConfig properties, and authorize Function Compute to access logs.
Create a service.
Note: You can add service descriptions and configurations when creating a service. Here, service descriptions and configurations are provided for demonstrating the subsequent update operation.
Create a log project and Logstore.
mkl -p fc-log-project -s fc-log-store
Update the service.
ups my-service -d "this is my service" -p fc-log-project -l fc-log-store
View the service.