Related Operations For Alias Management

Last updated: 2023-09-28 09:33:12

Overview

An alias in Serverless Cloud Function (SCF) is a pointer that directs to a bound function version. By using an alias, you can invoke the bound function. In practical development, aliases can assist you in managing project version updates and rollbacks more effectively. A single function version can have one or more aliases. For more information on function version management, please refer to the Overview of Version Management.

Use case

Through the configuration of aliases, you can create distinctions for multiple different environments (stages) for a function. For instance:
By creating 'test' and 'release' aliases and configuring triggers to point to these aliases, different codes and configurations can be activated.
You can use aliases to bind different function versions. Once a version has been validated in the test environment, you can redirect the traffic of the production environment to the new version through route configuration. For the method of traffic route configuration, please refer to Traffic Routing Configuration Instructions.

Default Alias

Upon creation, a function has a default alias ($DEFAULT) that points to the most recent version ($LATEST). The default alias cannot be deleted or renamed, but it does support traffic routing configuration.

Usage of Default Alias

When configuring triggers and invoking functions through the Cloud API, it is recommended to set the Qualifier parameter during the call to the default alias ($DEFAULT).
Instructions
By configuring the default alias, you can control the routing of default traffic generated by triggers and Cloud API calls.

Triggering an Alias

Currently, all aliases created for cloud functions can independently bind triggers. The invocation of the trigger will pass through the alias and pull up the specific version to execute based on the routing configuration of the alias.

Procedure

Create Alias

1. Log in to the Serverless console and click on Function Service in the left navigation bar.
2. On the "Function Service" list page, click on the function name to enter the details page of that function.
3. Select Operation > Create Alias in the upper right corner of the page, as shown in the figure below:


4. In the "Create Alias" pop-up window that appears, refer to the following information to create. As shown in the figure below:
Note
Once the alias is created, the alias name cannot be modified.


The main parameters are described as follows:
Alias Name: Custom name. It should be between 2 and 60 characters long, start with a letter, and can include a - z, A - Z, 0 - 9, -, _. It must end with a digit or a letter, for example, Tencent-cloud_scf.
Alias Description: Custom description. It can be up to 1000 characters long and may include English letters, numbers, spaces, commas, periods, and Chinese characters.
Route Method and Version Weight Configuration: For more details, refer to Traffic Routing Configuration.
5. Click Submit to complete the creation.

Modify the alias bound to the function version.

1. Select Operation > Traffic Settings in the upper right corner of the function details page. As shown below:


2. In the pop-up "Traffic Settings" window, configure as per the instructions below. As shown in the figure:

The main parameters are as follows:
Alias: From the dropdown list, select the alias you wish to bind to this version. In this document, test02 is used as an example.
Route Method and Version Weight Configuration: For configuration details, please refer to Traffic Routing Configuration. This document uses the modification of the alias bound to the $LATEST version as an example:
Select the routing method as Weighted Routing.
The version weight configuration is as follows: The weighted routing for version $LATEST is 70%, and the weighted routing for version 1 is 30%.
3. Click Submit to complete the changes. Open the version dropdown list to view the effect of the modifications. As shown in the figure:



Deleting alias

Note
This action only permanently deletes the alias, excluding the underlying version codes and configurations.
1. Select Operation > Delete Alias in the upper right corner of the function details page. As shown in the figure:


2. In the "Delete Alias" pop-up window, select the alias you wish to delete from the dropdown list and click Submit. This document uses the deletion of alias test02 as an example. As shown in the figure: