Function Compute allows you to create an alias for a service version. You can use the alias feature together with the versioning feature to implement continuous integration (CI) and continuous delivery (CD) in software development lifecycles. This topic describes how to manage aliases in the Function Compute console.
What is an alias?
Function Compute allows you to create an alias for a service version. An alias can be regarded as a pointer to a specific version of a service. You can use an alias to perform version publish, rollback, or canary release with ease. An alias is dependent on a service or a version. When you use an alias to access a service or function, Function Compute parses the alias into the version to which the alias points. This way, the caller does not need to know the specific version to which the alias points.
For example, without aliases, you must modify the version number that is associated with the HTTP trigger of a function when a new service version is published. However, the modification affects user experience on the client. If you use aliases to manage versions, you can implement smooth upgrade of versions. The following figure shows the version publish process. In this example, the alias PROD is configured to point to Version 1. The client directly uses the alias PROD to invoke functions in the service of Version 1.
After Version 1 is published, you can continue to develop new features over the LATEST version. The client uses an alias to invoke functions in the service of the related version. To publish Version 2, you need to only change the pointing of alias PROD to Version 2. When the client invokes functions, Version 2 is parsed out. This way, the version is iterated and updated. In addition, you can change the version to which the alias points to an earlier version to roll back the version. For example, you can change the version to which the alias PROD points to a version earlier than Version 1. This way, you can publish a version without deteriorating user experience on the client.
Creates an alias
- Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
- In the top navigation bar, select a region. On the Services page, click the desired service.
- In the left-side navigation pane, click Aliases. On the Aliases page, click Create Alias.
- In the Create Alias panel, configure the alias and click OK.
The following table describes the parameters that are used to create an alias.
Enter the name of the alias that you want to create.
Enter the description of the alias.
Specify the major version of the alias.
Enable Canary Release
Specify whether to enable the canary release version. To enable canary release, select Yes and configure the following parameters based on your business requirements.
Canary Release Version
Specify the canary release version of the alias.
Canary Release Type
Select a canary release type, which can be Random or By Rules.
Random: Specify a weight to divert a proportion of traffic to the canary release version.
By Rules: Specify the rules based on which the canary release is performed.
By Rules takes effect only when you use an HTTP trigger to call an alias.
Canary Release Version Weight
Specify the weight of canary release version. This parameter is required if you set Canary Release Type to Random.
The value of this parameter specifies the percentage of traffic diverted to the canary release version. For example, if you set the value to 5%, Function Compute diverts 5% of the traffic to the canary release version and 95% of the traffic to the major version.
Specify the rule mode. This parameter is required if you set Canary Release Type to By Rules.
This parameter specifies the mode to match the specified rules. Valid values:
Specify the rules. This parameter is required if you set Canary Release Type to By Rules.
Each rule contains the following fields:
Parameter Type: Specify the type of the parameter. Valid values: Header, Cookie, and Query.
Parameter: Specify the name of the parameter that is used to control the canary release.
Condition: Specify the condition for comparison. When a request is submitted, Function Compute compares the actual value of the parameter in Parameter and the parameter value that you specify based on the specified condition. If the condition is matched, the request is routed to the canary release version. Valid values:
=, !=, >, <, >=, <=: comparison operators. For example, if you set Condition to
=, the request is routed to the canary release version only when the actual value of the request parameter is equal to the specified value.
Include: the string matching condition. A request is routed to the canary release version only when the actual values of the request parameters are included in the value of Value.
Value Distribution: Perform the canary release based on the distribution of specified parameter values. For example, if you set Parameter Type to Header, Parameter to
user-id, and Value to
20, 20% HTTP requests are routed to the canary release version based on the distribution of the values of the request header
Value: Specify the parameter value that is used to control the canary release.
You can click + Add Rule to add more rules.
Canary Release Weight of Provisioned Instances
Specify the proportion to control the canary release weight of instances in provisioned mode. If the number of provisioned instances is greater than 1, Function Compute generates instances based on the specified weight. If you do not specify this parameter, the default weight is 1%.Important
The value of this parameter is valid only when the number of provisioned instances is greater than 1.On the Aliases page, the alias that you created appears. You can also modify or delete the aliases that are no longer needed. You can click Logstore that corresponds to the desired alias in the Actions column to go to the Log Service console to view logs.
Aside from the Function Compute console, you can also use Serverless Devs to configure aliases for a service. For more information, see Serverless Devs commands.