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 and updates in software development lifecycles. This topic describes aliases in Function Compute. This topic also describes how to create, update, view, and delete an alias 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, if no aliases exist, 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

Procedure

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

    The following table describes the parameters that you need to configure for an alias.

    Parameter Description Example
    Name The name of the alias. alias
    Description The description of the alias. None
    Major Version Select a major version that is stable. 1
    Canary Release Version If you want to divert a specific amount of traffic to the canary release version, you must select Yes. Otherwise, you can use the default value No. Yes
    Canary Release Version The version that you want to use for canary release. If you want to divert a specific amount of traffic to the canary release version, you must specify a value for this parameter. 2
    Canary Release Version Weight The weight of the canary version. The value of this parameter determines the ratio of traffic that you want to divert to the canary version. If you want to divert a specific amount of traffic to the canary release version, you must specify a value for this parameter. 5
    On the Aliases page, the alias that you created appears. In this example, the alias points to Version 1, the canary release version is Version 2, and the weight of the canary release version is 5%. You can also modify or delete the versions that are no longer needed. You can click Logstore that corresponds to the desired version 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 points to the alias are retained.

References

Aside from the Function Compute console, you can also use Serverless Devs to configure aliases for a service. For more information, see Basic features.