Function Compute offers a version management feature that enhances the efficiency of managing functions and triggers. This feature allows you to publish multiple function versions, facilitating continuous integration and deployment within the software development lifecycle while ensuring function stability and reliability.
What is a version
Function Compute enables function-level versioning, which allows you to publish one or more versions of your functions. Publishing a version creates an immutable snapshot that includes the function's code and configuration but excludes triggers, asynchronous task configurations, and reserved policy resource properties. Each published version is automatically assigned a unique version number, creating a distinct version entity. You can configure triggers and asynchronous tasks for each version separately, while aliases must be used to manage reserved policies.
Without versioning, any change to a function directly impacts the production environment, and release timings are uncontrollable. Versioning enables you to test and stabilize a function version before deploying it to handle online requests, while continuing development and testing on the LATEST version. The diagram below illustrates this mechanism.
The version snapshot includes essential function information such as the runtime environment, handler, and startup command, along with instance configuration details like instance type, concurrency, and instance lifecycle hook. It also encompasses function layers, environment variables, log configuration, network configuration, storage configuration, DNS configuration, health checks, and permission settings. Switching versions does not require modifications to the function code or these configurations.
The table below compares the configuration items that can be associated with versions and aliases. An indicates support for binding to the project, while an
signifies no support for binding.
Configuration type | Version | Alias |
Code logic | ||
```html Instance type, Single instance concurrency, Instance lifecycle hook configuration | ||
Layer, Environment variable, Log configuration, Network configuration, Storage configuration, Health check configuration, DNS configuration, Permission (Role) configuration |
Precautions
A new function includes the default LATEST version. Until you publish other versions, the LATEST version is the only one available and cannot be deleted.
Once published, a version cannot be altered. Version numbers increase sequentially and are not reusable.
Prerequisites
You must create a function before managing versions.
Publish a version
Log on to the Function Compute console and click Functions in the left-side navigation pane.
In the top menu bar, select a region, and then on the Functions page, click the target function.
Select the Version Management tab. On the version page, click Publish Version, enter the version description in the panel to publish a new version of the function, and then click OK.
Once the version is published, it will appear in the Version Management tab list. You can delete unnecessary versions and set a specific version as the primary or canary version for an alias as needed.
When deleting a version, only the function and its configurations are removed. Any aliases or triggers pointing to that version remain. It is advisable to detach any aliases and triggers before deleting a version to avoid errors when calling the alias.
References
To set a specific version as the primary or canary version of an alias, refer to Alias Management and Canary Release Implementation.
For configuring function versions using Serverless Devs, see Function Version Operations.