All Products
Search
Document Center

Using version in context

Last Updated: Dec 08, 2018

During funciton execution, you can get version information during runtime from ContextObject.

  • qualifier:The version information passed in when the function is called, either the version number or an alias.
  • versionId:The specific version number that is resolved from qualifier when the function is executed.

incontext

For example, you have an alias Prod pointing to major version 1 and additional version 2. When the function is called by the alias Prod, the value of the qualifier is Prod. If the major version is called, the value of versionId is 1; if the additional version is called, the value of versionId is 2.

The following is an example of the nodejs code that gets the qualifier and versionId from context:

  1. module.exports.handler = function(eventBuf, context, callback) {
  2. var qualifier = context['service']['qualifier']
  3. var versionId = context['service']['versionId']
  4. console.log('Qualifier from context:', qualifier);
  5. console.log('VersionId from context: ', versionId);
  6. callback(null, 'Success');
  7. };