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.

Figure 1. Version 1
version1

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.

Figure 2. Version 2
version2

Prerequisites

Creates an alias

  1. Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
  2. In the top navigation bar, select a region. On the Services page, click the desired service.
  3. In the left-side navigation pane, click Aliases. On the Aliases page, click Create Alias.
  4. In the Create Alias panel, configure the alias and click OK.

    The following table describes the parameters that are used to create an alias.

    Parameter Description
    Name Enter the name of the alias that you want to create.
    Description Enter the description of the alias.
    Major Version Specify the major version of the alias.
    Canary Release Version Specify whether to enable the canary release version.
    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.
    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 this parameter to 5%, Function Compute allocates 5% of the traffic to the canary release version and 95% of the traffic to the major version.

    Rule Mode 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:
    • Meet All
    • Meet Any
    Rules Configure the canary release 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: Select a condition for calculation. 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 met, the request is routed to the canary release version. Valid values:
      • =, !=, >, <, >=, <=: caparison conditions for calculation. For example, if you set Condition to =, a request is routed to the canary release version only when the actual values of the request parameters are equal to the value of 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 user-id.
    • Value: Specify the parameter value that is used to control the canary release.

    You can click + Add Rule to add more rules.

    Advanced options
    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.
Note When you delete an alias, only the alias is deleted. The version to which the alias points and triggers that point to the alias are retained.

Additional information

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.