All Products
Search
Document Center

Function Compute:Manage aliases

Last Updated:Jun 21, 2024

Function Compute allows you to create aliases for versions. You can use the alias feature together with the versioning feature to implement continuous integration and continuous deployment (CI/CD) in software development lifecycles. This topic introduces the concept of aliases and describes how to manage aliases in the Function Compute console.

What is an alias?

Function Compute allows you to create aliases for function versions. An alias can be regarded as a pointer to specific versions. You can use an alias to perform version publishing, rollback, or canary release with ease. An alias cannot exist independently without being associated with a function or a version. When you use an alias to access a function, Function Compute parses the alias into the versions to which the alias points. This way, the caller does not need to know the specific versions 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 version is published. This affects user experience on clients. You can implement smooth upgrade of versions if you use aliases to manage versions. The following figure shows the version publishing process. In this example, Alias PROD is configured to point to Version 1. A client can directly use Alias PROD to invoke the function of Version 1.

Figure 1. Release Version 1

image

After Version 1 is published, you can continue to develop new features on the LATEST version. Clients use the alias to invoke the function of specific versions. When Version 2 is published, you need to only point Alias PROD to Version 2. In this case, the system parses the alias to Version 2 when a client invokes the function based on Alias PROD. This method helps implement easy version update and iteration.

You can also point Alias PROD to Version 1 again to perform a rollback. This operation does not affect usage on the clients.

Figure 2. Release Version 2

image

You can also use aliases to manage traffic distribution during a canary release. For example, you can divert 5% of online traffic to Version 2 for verification by using an alias before you incrementally increase the traffic directed to Version 2 when Version 2 proves stable. This approach minimizes the risks associated with deploying a new version.

Figure 3. Canary release

image

Before you start

Create an alias

  1. Log on to the Function Compute console. In the left-side navigation pane, click Functions.

  2. In the top navigation bar, select a region. On the Functions page, click the function that you want to manage.

  3. On the function details page, click the Aliases tab. On the page that appears, click Create Alias.

  4. In the Create Alias panel, configure the parameters and click OK.

    The following table describes the parameters.

    Parameter

    Description

    Name

    Enter a name for the alias that you want to create.

    Description

    Enter a description for the alias.

    Major Version

    Specify the major version of the alias.

    Enable Canary Release

    Specify whether to enable the canary release feature. To enable canary release, select Yes and configure the following parameters based on your business requirements.

    Canary Release Version

    Specify a canary release version.

    Canary Release Version Weight

    Specify a percentage of traffic to divert 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.

    On the Aliases tab, you can view the created alias. You can also edit existing aliases and delete aliases that you no longer use based on your business requirements.

Note

When you delete an alias, only the alias is deleted. The versions to which the alias points and triggers that point to the alias are retained.

More information

In addition to the console, you can use Serverless Devs to configure an alias for a function. For more information, see Common commands of Serverless Devs.