After a version is created, you can use an alias to manage the version. The caller
can call the correct service version by using the alias without knowing the service
version.
Step 1: Create an alias
- Log on to the Function Compute console.
- In the top navigation bar, select a region.
- In the left-side navigation pane, click Service/Function.
- Click the target service named service, and then click the Versions tab.
- In the version list, find the version for which you want to create an alias. Then,
click Create Alias in the Actions column.
- In the Create Alias dialog box, modify the alias and click OK.
Click the
Alias tab. You can see the created alias named alias and version 1 to which the alias points.

(Optional) Step 2: Use the alias in a trigger
If you have created a trigger for your function, you can associate the trigger with
the alias. In this way, when the online version is switched, the trigger will not
be affected and can be smoothly switched to the version to which the alias points.
This topic uses an Object Storage Service (OSS) trigger as an example to describe
how to use an alias in a trigger.
Note A trigger has no version but can point to a specific service version or alias.
- On the Service/Function page, find the target service named service.
- In the upper-right corner of the function list, select LATEST from the Service Version
drop-down list. Then, click the target function name.
- On the function details page, click the Triggers tab.
- In the trigger list, click the target trigger name.
- On the Edit Trigger page, change the value of Version/Alias from LATEST to the alias that you created. Click OK.
Step 3: Run the function associated with the specified alias
In the Function Compute console or by calling the Function Compute API, you can verify
whether the function for the service of the correct version is executed.
Run the function associated with the specified alias in the Function Compute console
- On the Service/Function page, find the target service named service.
- Click the target function name.
- In the upper-right corner of the function details page, select PROD on the Alias tab from the Service Version drop-down list.
- Click the Code tab.
- Click Invoke.
After the function code is executed, you can view the execution log at the lower part
of the page. In the log, you can see that the value of the
qualifier field that indicates the version information is PROD and the
versionId field that indicates the parsing result is 1. The log shows that the executed function
belongs to the service associated with alias PROD and the alias points to version
1.

Run a function associated with a specified alias by calling the Function Compute APITo enable the system to run a function associated with a specified alias, you can
append a period (.) as a separator to serviceName in the request path and use qualifier to specify the alias. The request is in the following format:
POST /services/{serviceName}.{qualifier}/functions/{functionName}/invocations
The sample request is as follows:
POST /services/{service}.{qualifier}/functions/{function}/invocations
API operations that support similar usage are as follows:
Step 4: Publish an additional version
After a new version is developed, you need to use an additional version to ensure
that the new version is stable.
- Publish a new version. For more information, see Publish a version.
After the version is published, you can view the newly published version in the version
list.

- On the Versions tab, click the Alias tab.
- In the alias list, find alias PROD that points to version 1 and was created in Step 1. Then, click Update Alias in the Actions column.
- In the Update Alias dialog box, set the additional version to the new version and enter the weight of
the additional version. Click OK.
After the configuration is completed, the specified percentage of the traffic is switched
to the service of the new version.
Step 5: Switch all traffic to the new version
After the additional version runs stably, you can switch all online traffic to the
service of the new version.
- On the Versions tab, click the Alias tab.
- In the alias list, find alias PROD that points to version 1 and additional version
2 published in Step 4. Then, click Update Alias in the Actions column.
- In the Update Alias dialog box, set the major version to the new version and leave Additional Version
ID empty. Click OK.
After the configuration is completed, all of your online traffic is switched to the
service of the new version.