skip to content

On a function platform, what is the difference between a published version and an alias, and why do triggers call the alias?

level: juniorimportance: must knowfreq 70%

answer

  1. frozen snapshot vs movable name
  2. code plus configuration, never edited
  3. release by repointing
  4. rollback without a rebuild

basics

~20 s

A published version is an immutable snapshot of a function's code and configuration; an alias is a named pointer to one version. Triggers and callers invoke the alias, so releasing or rolling back is just repointing it.

solid answer

~50 s

Publishing a version freezes the function's code package together with its configuration (memory, timeout, deploy-time environment variables) under an identifier that never changes. An alias such as `live` is a mutable, named pointer to one of those versions and holds no code of its own. API routes, schedules and event triggers are wired to the alias, never to a bare version number or to an editable working copy. A release then becomes a pointer change: publish the new version, move the alias. Rollback is the same move in reverse and takes effect for new invocations almost at once, because the old version is still published and needs no rebuild. Immutability also lets you say exactly which code served a request, and many platforms report metrics per version so the two can be compared during a release.

go deeper

for a junior

Be able to say that a version is a frozen snapshot and an alias is a movable name, and that rolling back means moving the name back.

for a middle

Explain what a version freezes beyond code, such as memory, timeout and environment variables, and why triggers must reference the alias rather than an editable working copy.

for a senior

Show that you have audited what really routes through the alias: triggers pinned to versions, internal callers using the bare name, and whether old versions survive long enough to roll back to.

for a principal

Speak to the release contract a platform team sets: every production trigger through an alias, a retention policy for old versions, and the executed version in every log line.

## Why a function release needs its own primitive On a function platform there is no host to log into, no process to restart and no directory to copy files into. The platform owns the machines: you hand it a code package and configuration, and it starts sandboxes on demand. So a release cannot be "stop the server, swap the files, start it again". Most function platforms instead give an operator two objects that together make releases and rollbacks safe: the **published version** and the **alias**. ## Versions: immutable snapshots Publishing a **version** takes the function as it is now and freezes it under an identifier that never changes, usually an increasing number. What is frozen is more than the code: - the **code package**, as an archive or a container image digest - **runtime configuration** such as memory size, timeout and the runtime itself - **environment variables** set at deploy time - on many platforms, the handler entry point and any attached layers or extensions Because a version cannot be edited, `version 42` means the same thing today and in six months. That is what makes it a safe rollback target, and what lets you say exactly which code served a given request. Platforms that keep an editable working copy beside the published versions treat that copy as a draft: anything wired to it changes the moment someone deploys. ## Aliases: named pointers An **alias** is a stable name, such as `live` or `staging`, that points at one published version. It contains no code. Callers, API routes, schedules and event triggers reference the alias, so none of them needs to know a version number. Many platforms also let an alias point at two versions with weights, which is how a gradual traffic shift works. Some platforms express the same idea as traffic tags on immutable revisions rather than as a separate alias object; the operating model is the same. ## A release and a rollback, step by step 1. Build the code package and deploy it from a template that also declares the function's permissions, triggers and alias. 2. Publish a new version. It now exists but takes no traffic. 3. Move the alias to the new version, all at once or through a weighted shift. 4. Watch the new version's errors and latency. 5. To roll back, move the alias back to the previous version. Step 5 needs no build, no artifact download and no new version. The previous version is still published, so new invocations reach it almost immediately. The first requests may pay for fresh sandboxes, but nothing has to be rebuilt or re-uploaded while the incident is running. ## What must point at the alias The alias controls only the traffic that goes through it. The common leaks are: - **a trigger wired to the editable working copy**: every deploy reaches it at once, with no rollback target and no weighted shift - **a trigger pinned to a fixed version number**: it never receives a release until someone edits the trigger - **another function calling by bare name**: depending on the platform, that may resolve to the working copy rather than the alias - **a client that hard-codes a version**: every release then needs a client change ## Version, alias and working copy compared | | Published version | Alias | Editable working copy | |---|---|---|---| | Changes after creation | Never | Can be repointed | On every deploy | | Holds code | Yes | No, it points at a version | Yes | | Safe target for production triggers | Only when pinning is intended | Yes | No | | Role in a rollback | The target you return to | The thing you move | None | ## Habits that follow from the model - Keep enough old versions to roll back to, and prune old ones on a schedule rather than by hand in the middle of an incident. - Write the executed version into every structured log line, so any request can be tied to the exact code that served it. - Treat a configuration change as a release. On platforms with immutable versions, a changed environment variable means a new version and an alias move, which is why values that rotate on their own schedule, such as credentials, are usually read from a secret store at runtime instead. - Name aliases for their role (`live`, `staging`), not for a release, so that callers never need to change when a release ships.

  • Why is it risky to point a production trigger at a function's editable working copy instead of an alias?
    Every deploy reaches that trigger the moment it lands, with no review step and no weighted shift. There is no previous published version behind it to move back to, so a rollback means rebuilding and redeploying under pressure. Per-version metrics also stop meaning much, because the code behind the trigger changes without a new identifier.
  • If a published version's environment variable needs a new value, can you edit it in place?
    Not on a platform with immutable versions: the configuration is part of the version. You publish a new version carrying the changed value and move the alias to it, which is a release like any other. That cost is why values that rotate on their own schedule are usually read from a secret store at runtime instead of frozen into the version.

A published version is a printed edition of a book, and the alias is the "current edition" label on the library shelf. Readers follow the label; to withdraw a faulty edition, the librarian moves the label back to the previous edition, which is still printed and on the shelf.

  • Rolling back means rebuilding and redeploying the previous commit.
  • An alias is a copy of the code under another name.
  • Pointing production triggers at the latest deployed code is fine if tests pass.
  • Every caller should switch to the newest version number at each release.
  • Editing an environment variable on a published version updates it in place.