Function Compute allows you to manage aliases. An alias is a resource used for version management. You can use aliases and versions to implement continuous integration and continuous delivery in the software development lifecycle.

Definition

As a resource in Function Compute, an alias can be considered as a pointer to a specific service version. 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.

Function Compute allows you to create an alias for a service version. An alias points to a specific service version and can be modified. An alias cannot point to other aliases. You can use an alias to publish, roll back, or canary release a version with ease.

Assume that a third party triggers your function by using an HTTP trigger and no aliases are configured for your service. Each time a new service version is published, you must manually modify the version associated with the HTTP trigger, and the modification affects user experience on the client. In contrast, if you use an alias to manage the version, you can hitlessly upgrade the version.

For example, you can set the alias PROD to point to stable Version 1. If a trigger is created for your function, you can associate the trigger with the alias PROD. For more information, see the "Step 2: Use the alias in a trigger (Optional)" section of the Use an alias to switch traffic topic. The client directly uses the alias PROD to invoke the function in the service of Version 1.

Figure 1. Publish 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 corresponding version. To publish Version 2, you need only to change the alias PROD to the alias that points to Version 2. When the client invokes functions, Version 2 is parsed out. This way, the version is 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 frequently updating triggers or deteriorating user experience on the client.

Figure 2. Publish Version 2
version2

Alias parameters

When you create an alias, you must set the parameters that are described in the following table.

Note You can modify all parameters subsequently except AliasName.
Parameter Required Description
AliasName Yes The name of the alias. The name must be unique in the current service and meet the following requirements:
  • The name can contain letters, digits, underscores (_), and hyphens (-).
  • The name must start with a letter or an underscore (_).
  • The name is case-sensitive.
  • The name must be 1 to 128 characters in length.
  • The alias name cannot be LATEST. This name is the default name reserved by Function Compute.
VersionId Yes The version to which the alias points. An alias cannot point to the LATEST version reserved by Function Compute.
Description No The description of the alias.
AdditionalVersionWeight No The canary release version to which the alias points and the weight of the canary release version.
  • The canary release version takes effect only when the function is invoked.
  • The value consists of a version number and the corresponding weight. For example, 2:0.05 indicates that when a function is invoked, Version 2 is the canary release version, 5% of the traffic is distributed to the canary release version, and 95% of the traffic is distributed to the major version.