Skip to content

Publish, promote and use aliases

Publishing and promoting are separate on purpose. Publishing a version changes nothing that is running. Promoting a version to live is the moment it takes effect, and the moment its subscriptions and schedules are created, updated or removed to match what the version declares.

Concept Meaning
Address {application}.{name}, for example billing.invoice-pdf. It never changes.
Version One published build, numbered 1, 2, 3 and immutable. Identified by the sha256 digest of the bundle.
Alias A name pointing at a version. live is what subscriptions, schedules and ordinary calls reach. Other aliases (qa, canary) are reachable over HTTP only.
Terminal window
fcdev fn deploy billing.invoice-pdf . --create # build, publish, wait until loaded, promote live
fcdev fn set billing.invoice-pdf --config GREETING=Hi --secret STRIPE_KEY=sk_...
fcdev fn publish billing.invoice-pdf function.wasm # publish only
fcdev fn promote billing.invoice-pdf 7 # point live at version 7 (--alias qa for another alias)
fcdev fn invoke billing.invoice-pdf@qa hello/Aroha # call through a runner
fcdev fn status billing.invoice-pdf
  • A version must be loaded by a runner before it can be promoted. deploy waits for this, then promotes.
  • Promotion is refused while a config key, secret or database the version declares has no value. If deploy stops for that reason, fcdev fn set the missing values and fcdev fn promote the version. See Give a function secrets and config.
  • deploy of a Java jar picks the JVM runtime from the .jar extension. A function’s runtime is fixed from its first version.
  • A promote is also a rollback: promoting an older version back restores its wiring too.

Reference for every flag: fcdev CLI.

Publish, point qa or canary at the new version, test it over HTTP, then promote it to live:

Terminal window
fcdev fn publish billing.invoice-pdf function.wasm # prints the new version number
fcdev fn promote billing.invoice-pdf 8 --alias qa
fcdev fn invoke billing.invoice-pdf@qa hello/Aroha # @vN also calls one exact version
fcdev fn promote billing.invoice-pdf 8 # live

Only live is wired to subscriptions and schedules. A public route can point at a named alias (the route’s alias field; empty means live).

A function keeps its 20 most recent untagged versions (platform setting FC_FUNCTIONS_KEEP_VERSIONS). After each publish, older untagged versions are deleted for good: the version record and its stored artifact. A version is tagged when any alias points at it; tagged versions are never deleted and do not count towards the 20. The newest version, and a version published in the last hour that no runner has loaded yet, are never deleted either. Version numbers are never reused, so billing.invoice-pdf@v7 never means two different builds. To keep a build for good, point an alias at it.

Terminal window
fcdev fn prune billing.invoice-pdf --dry-run
fcdev fn prune billing.invoice-pdf # or --keep 10

The API is POST /api/functions/{id}/versions/prune.

fcdev fn talks to the platform as an OAuth client. Against a local fcdev it signs in by itself. Against a remote platform it uses a profile, a named target with one of two ways to authenticate:

  • A person (--login): you sign in with your browser and act as yourself, with your own roles. No client id or secret exists anywhere.
  • A client (--client-id): for CI and service accounts. The secret is held by reference (OS keychain, environment variable, file or command), never in the profile file.
Terminal window
fcdev profile add np --platform https://np.example.com --env np --login
fcdev login --profile np
fcdev fn status billing.invoice-pdf --profile np
# CI or a service account
fcdev profile add np-ci --platform https://np.example.com --env np \
--client-id fc_client_abc --secret-ref env:FC_CLIENT_SECRET

Rules worth knowing:

  • With --profile NAME (or FC_PROFILE) the profile fully determines the platform URL, runner URL and credentials; --platform, --client-id and --client-secret alongside it are refused.
  • A non-loopback target without a profile is refused. Profile URLs must be https unless loopback.
  • Every fn command that talks to a platform prints a banner first, for example profile prod-eu (prod) https://fc.example.com.
  • Commands that change remote state (publish, promote, deploy, set, delete, and invoke with any method other than GET or HEAD) against a profile with env = "prod" make you type prod. --yes does not bypass this on a terminal. Without a terminal the command is refused unless you pass --yes and the profile has allow_noninteractive = true. The prod tag is a convention you set: a prod platform registered with --env np is not protected.
  • fcdev fn deploy --dry-run builds, validates the describe, looks the function up (read-only) and prints what would be created, published and promoted.
  • A login lasts 7 days from sign-in (FC_FCDEV_LOGIN_REFRESH_TTL_SECS), then you sign in again. It needs a terminal and a platform release that includes the fcdev-cli client.

The profile file is profiles.toml under the user config directory (override with FC_PROFILES_PATH), must not be group- or other-writable, and never holds a secret.

Do not give a nonprod or prod CLI credential super-admin. Create a service account and grant it the smallest role that fits:

Role Allows
platform:function-deployer function view and manage, version publish, alias promote, client and application view. The one role for CI running deploy --create --client <code>. Function manage also permits deleting functions
platform:function-publisher view, publish and promote only: enough for publish, promote, status and deploy of a function that already exists

For set --secret and --db you also need platform:function:secret:manage; invoke with a token needs platform:function:version:invoke. --client takes a client’s identifier or its clt_ id and is only consulted when the function is created.

A pipeline should deploy only when the function changed, decided by the artifact’s digest.

Terminal window
fcdev profile add ci --platform "$FC_PLATFORM_URL" --env prod --allow-noninteractive \
--client-id "$FC_CLIENT_ID" --secret-ref env:FC_CLIENT_SECRET
fcdev profile test ci
fcdev fn deploy myapp.myfn ./fn --profile ci --yes --skip-unchanged --json > deploy.json
Situation What deploy does
new digest publish, wait until a runner has proved it loadable, promote live
--no-promote, new digest publish and wait; live is not moved
--skip-unchanged, live already has this digest prints unchanged: ..., exits 0, no remote write, no confirmation
--skip-unchanged, digest is a version but not live no upload, but it is promoted (unless --no-promote)
the digest’s version is FAILED never skipped: re-published (the same version is re-queued), waited for, then promoted

--json prints exactly one JSON object on stdout (address, functionId, version, digest, created, promoted, skipped, runtime, client), with progress on stderr.

What changes the digest. The digest is the sha256 of the bundle bytes, so anything that changes the bytes is a new version: source, values baked in at build time, dependency versions (commit the lockfile and use npm ci), the bundler version (pin it exactly), and the relative paths of linked dependencies outside the project. Go builds use -trimpath; use the same toolchain version in CI and commit go.sum or Cargo.lock. When a digest changes without a source change, diff the two bundles.

A Java function is served by the ingestor runtime, not the WebAssembly runner. Where you deploy, set FC_FUNCTIONS_RUNNER_URL_JVM on the platform to the ingestor’s URL ({pool} is substituted, as in FC_FUNCTIONS_RUNNER_URL), and give the ingestor’s service account platform:function-runner as well as platform:ingestion-runtime. See Environment variables and Ingestion under fcdev.