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. |
The commands
Section titled “The commands”fcdev fn deploy billing.invoice-pdf . --create # build, publish, wait until loaded, promote livefcdev fn set billing.invoice-pdf --config GREETING=Hi --secret STRIPE_KEY=sk_...fcdev fn publish billing.invoice-pdf function.wasm # publish onlyfcdev 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 runnerfcdev fn status billing.invoice-pdf- A version must be loaded by a runner before it can be promoted.
deploywaits for this, then promotes. - Promotion is refused while a config key, secret or database the version declares has no value.
If
deploystops for that reason,fcdev fn setthe missing values andfcdev fn promotethe version. See Give a function secrets and config. deployof a Java jar picks the JVM runtime from the.jarextension. 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.
Use aliases for staged rollouts
Section titled “Use aliases for staged rollouts”Publish, point qa or canary at the new version, test it over HTTP, then promote it to live:
fcdev fn publish billing.invoice-pdf function.wasm # prints the new version numberfcdev fn promote billing.invoice-pdf 8 --alias qafcdev fn invoke billing.invoice-pdf@qa hello/Aroha # @vN also calls one exact versionfcdev fn promote billing.invoice-pdf 8 # liveOnly live is wired to subscriptions and schedules. A public route can point at a named alias (the
route’s alias field; empty means live).
Old versions are pruned
Section titled “Old versions are pruned”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.
fcdev fn prune billing.invoice-pdf --dry-runfcdev fn prune billing.invoice-pdf # or --keep 10The API is POST /api/functions/{id}/versions/prune.
Deploy to a remote platform: profiles
Section titled “Deploy to a remote platform: profiles”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.
fcdev profile add np --platform https://np.example.com --env np --loginfcdev login --profile npfcdev fn status billing.invoice-pdf --profile np
# CI or a service accountfcdev profile add np-ci --platform https://np.example.com --env np \ --client-id fc_client_abc --secret-ref env:FC_CLIENT_SECRETRules worth knowing:
- With
--profile NAME(orFC_PROFILE) the profile fully determines the platform URL, runner URL and credentials;--platform,--client-idand--client-secretalongside it are refused. - A non-loopback target without a profile is refused. Profile URLs must be
httpsunless loopback. - Every
fncommand that talks to a platform prints a banner first, for exampleprofile prod-eu (prod) https://fc.example.com. - Commands that change remote state (
publish,promote,deploy,set,delete, andinvokewith any method other than GET or HEAD) against a profile withenv = "prod"make you typeprod.--yesdoes not bypass this on a terminal. Without a terminal the command is refused unless you pass--yesand the profile hasallow_noninteractive = true. Theprodtag is a convention you set: a prod platform registered with--env npis not protected. fcdev fn deploy --dry-runbuilds, 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 thefcdev-cliclient.
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.
Least privilege
Section titled “Least privilege”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.
Deploy from CI
Section titled “Deploy from CI”A pipeline should deploy only when the function changed, decided by the artifact’s digest.
fcdev profile add ci --platform "$FC_PLATFORM_URL" --env prod --allow-noninteractive \ --client-id "$FC_CLIENT_ID" --secret-ref env:FC_CLIENT_SECRETfcdev profile test cifcdev 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.
Where JVM functions run
Section titled “Where JVM functions run”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.