Function Compute supports the versioning feature to help you efficiently manage functions and triggers. You can publish multiple versions of a function to implement continuous integration and continuous deployment (CI/CD) throughout the software development lifecycle and ensure the stability and reliability of the function.
What is a version?
Function Compute delivers granular version control at the function level, allowing you to publish multiple versions of your functions as needed. Publishing a version captures the current code and configuration as an immutable baseline, while resource attributes, such as triggers, asynchronous task settings, and scaling policies, are excluded from this baseline. Triggers and asynchronous tasks can be configured independently for each version, whereas scaling policies are managed exclusively through aliases.
Without versioning, any alterations to your function immediately affect the production environment, leaving no control over the timing for deploying updates. The versioning feature allows you to publish a stable function version after testing to serve online requests while continuing development and testing on the LATEST version of the function. The following diagram illustrates this mechanism.
A released version includes essential function information, such as the runtime, handler, and startup command, along with instance configuration details like the instance type, concurrency, and lifecycle hooks. It also encompasses function layers, environment variables, log configurations, network settings, storage configurations, DNS configurations, health checks, and permission settings. Switching versions does not require any modifications to the function code or these configurations.
The following table lists the configuration items that can be associated with versions and/or aliases. A
indicates that the configuration item supports binding to a version or an alias, while a
signifies that it does not support binding.
Configuration items | Version | Alias |
Code logic |
|
|
|
| |
Instance specifications, instance concurrency, instance lifecycle hook |
|
|
|
| |
|
| |
|
| |
Layer, environment variable, logging, network, storage, health check, custom DNS, permissions (role) |
|
|
Considerations
A newly created function comes with the default LATEST version. Before you publish any versions, the LATEST version is the sole version of the function and cannot be deleted.
A published version cannot be modified. The version number monotonically increases and cannot be reused.
Prerequisites
A function is created. For more information, see Create a function.
Publish a version
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the function that you want to manage.
Click the Versions tab. On the Versions tab, click Publish Version. In the Publish Version panel, enter the version description and click OK.
After a version is published, you can find it in the Versions tab. You can delete the versions that you no longer need and also set a version as the major or canary release version of an alias as prompted.
When you delete a version, only the function and configurations within that version are removed. The aliases pointing to the version and the version's triggers are retained. Therefore, we recommend that you first remove any aliases and triggers associated with the version before deleting it. Otherwise, an error will occur if you try to call an alias that points to the version.
References
For more information about how to set a specified version as the major or canary release version of an alias, see Manage aliases and Use versions and aliases to implement canary release.
In addition to the Function Compute console, you can use Serverless Devs to publish function versions. For more information, see User guide for version.