Deployments
A deployment is one release of the application, with all its hosts. Vox lets a new release start next to the old one, eg in a blue/green deployment, and moves the background work to it only when the deployment pipeline activates it. Both releases accept writes the whole time, so a public application stays up while traffic moves from one to the other.
Without a deployment id an application has one deployment, which is active from the start. That's the usual setup for development, and for a single host that's stopped before the next release starts. Everything on this page is about running two releases side by side.
One release, step by step
Take an application whose hosts run behind a load balancer. Blue, the current release, takes the traffic. The pipeline releases green:
- Start green's hosts next to blue's, with a new deployment id written into the package. Green's hosts start in standby: they migrate the model and accept writes, but don't run any background work.
- Activate green from the pipeline, and wait until the activation completed. Blue's hosts finish what they're doing, stop their background work and report that they're ready. Green's hosts take the work over. Blue keeps accepting writes, and green processes them.
- Move the traffic to green. While it moves, which can take a minute or more, some traffic still reaches blue, eg customers adding to their carts, and green processes those writes.
- Stop blue's hosts, retired.
Every host of one release gets the same deployment id, also when the processing runs in a separate application, and all of them are started before the activation, so the activation waits for them.
On Azure App Service, the new release runs in a staging deployment slot and the traffic moves with a slot swap, see
release with deployment slots.
Identities
A deployment's identities are options of VoxOptions.Deployment, which builder.AddVox reads from configuration:
{
"Vox": {
"Deployment": {
"DeploymentId": "run-1234-1",
"BuildId": "2026.11.30.1"
}
}
}
The deployment key, Vox:Deployment:ApiKey, is a secret and comes from a secret store, see
security.
- Deployment id: new for every deployment, and the same on every host of it, also when they restart or scale out.
A redeployment of the same build, eg a rollback, gets a new one, so it starts in standby like any new release. A
pipeline run id is a good value, eg
run-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}. At most 200 characters, without/. - Build id: the version that's deployed, for diagnostics only.
- Worker id: the identity of a host within the deployment, see worker ids.
The deployment id must travel with the code, not with the slot or machine it runs on. Write it into the published
package, eg with jq in a GitHub Actions workflow:
jq --arg id "run-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" '.Vox.Deployment.DeploymentId = $id' publish/appsettings.json > tmp.json && mv tmp.json publish/appsettings.json
Don't take it from where the release runs, eg an App Service slot's name or a deployment slot setting: they stay with the slot during a swap, see configuration and secrets.
Activate from the pipeline
The pipeline activates the new deployment, polls until the activation completed, and only then moves the traffic:
base=https://app-staging.example.com/vox/api/deployment
key="X-Vox-Deployment-Key: $VOX_DEPLOYMENT_KEY"
attempt=$(curl -sf -X POST -H "$key" -H 'Content-Type: application/json' \
-d "{\"deploymentId\":\"$DEPLOYMENT_ID\"}" "$base/activations" | jq -r .attempt.attemptId) || exit 1
[ -n "$attempt" ] && [ "$attempt" != null ] || exit 1 # refused, eg another activation is pending
while true; do
status=$(curl -s -o progress.json -w '%{http_code}' -H "$key" "$base/progress?attemptId=$attempt")
case $status in
200) break ;; # completed: the new release processes
202) sleep 2 ;; # pending
*) cat progress.json; exit 1 ;; # failed, eg it timed out: the deployment failed
esac
done
| Endpoint | Answers |
|---|---|
POST {base}/activations with { "deploymentId": "..." } | 202 Accepted with the attempt at once. The same request again returns the same attempt. 409 Conflict while another activation is pending, or failed and isn't resolved, when no host of the deployment has started, when the deployment is active already, or when it was retired. |
GET {base}/progress?attemptId=... | 202 Accepted while it's pending, 200 OK once it completed, 409 Conflict with the reason once it failed, or when another attempt has started since. Without attemptId, the current attempt, or 404 Not Found if none was ever requested. Every host's mode, heartbeat, readiness and progress are in hosts. |
POST {base}/activations/{attemptId}/resolve with { "note": "..." } | Resolves a failed attempt, so another can be requested, see when an activation fails. |
{base} is the API's base path and api/deployment, eg https://app.example.com/vox/api/deployment. The requests may
reach a host of either release, eg through the load balancer: the answer is the same whichever host gives it.
The deployment key. The endpoints are authenticated with the key in VoxOptions.Deployment.ApiKey, sent in the
X-Vox-Deployment-Key header. The pipeline gets it from its secrets. It's compared with the configured value only, so
the endpoints work while the database is busy, and a Vox user's credentials don't grant them. Without a configured key,
every request is refused.
What an activation does
- Blue's hosts are told to retire. Each one stops starting new background work, Nexus jobs, queue processors and functions, cancels the running ones and waits until they've stopped at a safe point. Then it hands its claims on the shared work over and reports that it's ready. It keeps accepting writes.
- Once every live blue host is ready, green takes the background work over and the activation completes. Green's hosts start their Vox loops, their Nexus jobs and the model migration steps that waited for an active deployment.
With a cross-machine broker, an activation completes in a few seconds. Without one, each step waits for a heartbeat, so it takes about two heartbeat intervals longer. A failing step, eg a database command that timed out, is tried again until the attempt's deadline.
A blue host that hasn't reported for longer than the liveness timeout (60 seconds) is taken for gone and doesn't hold the activation up, also one that dies during it, eg in a scale-in.
A retiring host no longer hears of changes made on other hosts, so its caches go stale: a cart saved on blue may be validated against a price that green changed a moment ago. Move the traffic as soon as the activation completed.
What each mode does
| Mode | Writes | Background work | Model migrations |
|---|---|---|---|
| Standby: new, until it's activated | Accepted | Doesn't run | Run, except the steps that need an active deployment |
| Active | Accepted | Runs | Run |
| Retiring: being replaced by an activation | Accepted | Stops at a safe point | Stop between batches |
| Retired | Accepted | Doesn't run | Don't run |
Background work here is Vox's own loops, the Nexus jobs of imports and publications, and the application's own Nexus jobs, queue processors and functions: all of them start only on a host whose deployment is active. A host that can't read its mode when it starts, eg since the database is unreachable, behaves as in standby until it can. The mode is kept in the database, so a host that restarts or scales out gets its deployment's mode back. Starting or restarting a host never makes a deployment active: only an activation does.
Every host accepts writes in every mode: entity writes from the API, MCP, the admin and the application's own code, publishing and releases, assets and imports. A write commits the entity together with the work it causes, and whichever deployment is active does that work: blue processes what a standby green writes, and green what a retired blue writes. Imports are enqueued on any host and applied by the active deployment.
The model migration steps that hand work to the processing, eg recalculating a calculation for every entity, wait for the deployment to be active, see model evolution.
After a compatible model change, blue's saves of the changed entity types are recorded, and green repairs what blue doesn't maintain, eg the links of a new relation, the values of a new unique property and the query storage of a new filter, from the stored entities. One of green's hosts runs the repair next to the model migrations, so also while green is on standby, and filters and unique checks on green are right before the activation. The context memberships that new values decide are recalculated once green is active, since blue's processing would recalculate them without the new values. Transient entity types on Redis aren't repaired.
What the application must do
Vox stops its own background work and reports its own readiness. It can't make the rest of an application safe for a live handover, so the application must:
- Stop its own background work on retirement. Custom background work that should only run on the active deployment
stops when
IVoxDeploymentLifecycle.RetirementTokenis cancelled. Nexus jobs, queue processors and functions are cancelled by Vox and must respect their cancellation tokens. - Run work-producing startup code when active. Mark an
IVoxStartupInitializerthat records work for the processing, eg because a setting in code changed, withRunsWhenActive, so it runs once its deployment is active instead of leaving the work to the old release's code. - Keep external side effects idempotent. Work that a retiring host didn't commit is done again by the new deployment.
- Move the traffic once the activation completed. Until then both releases write, and the old release's code does the background work of what the new one writes.
- Request the full build of a new publication sink once the release that adds it is active. The old release's processing doesn't know the sink and drops its state, a full build request included, see several sinks.
- Deploy with downtime when releases must not overlap, see below.
The first administrator of a new installation is created when the first host starts, also before the first activation: that's installation, not a write of the deployment. Seeders of sample data don't belong in a production deployment.
When to deploy with downtime
From when the new release starts until the old one is stopped, two releases of the application's code write at the same time. A save evaluates the saved entity's own calculations with the code of the release that saves it, so a cart saved through the old release has its totals calculated by the old code. Vox keeps the background work on one release at a time and refuses the writes that the stored model can't take, but it doesn't make every release safe to run side by side.
Stop the old release before starting the new one when the release:
- changes behavior that must never overlap with the old, eg how a cart total is calculated, when no total may ever be computed the old way after the release;
- makes an incompatible model change to an entity type that its public flows write.
vox migrate --plansays which changes are incompatible, see model evolution; - starts tracking a field with a tracked query, since the old release's saves don't capture it. Alternatively, recalculate the entity types that the query reads after the deployment, see calculations.
- adds a template to a field set that the old release's writers, eg its imports, write during the deployment: the old release refuses the saves of a product that is moved to the new template, see model evolution.
When an activation fails
An activation that hasn't completed within ActivationTimeout (3 minutes) fails. The progress endpoint answers
409 Conflict with the reason, eg which blue hosts weren't ready, and the pipeline must fail the deployment.
After a failed activation, green stays in standby and blue stays retiring. No deployment does background work until the attempt is resolved and a deployment is activated, while both keep accepting writes. A failed attempt stays failed: it isn't completed later when the hosts become ready, and no other activation can start until it's resolved.
A common cause is a blue host that is paused or overloaded for a minute, so its heartbeat is late. That's a failed deployment, not a reason to shorten the liveness timeout.
To recover, either:
- Redeploy through the pipeline. The new deployment gets a new deployment id, starts in standby, and is activated once the failed attempt is resolved.
- Stop blue and activate green again. Move the traffic to green, which accepts writes in standby, then stop blue's
hosts, also those of a separate processing app, resolve the failed attempt
(
POST {base}/activations/{attemptId}/resolve), and activate green again. Blue's stopped hosts don't hold the new activation up once they've been silent for longer than the liveness timeout. If green's hosts were stopped too, start them first.
Resolving makes no deployment active: only an activation does.
Rolling back
Roll back by deploying the old version again through the same pipeline. It gets a new deployment id, starts in standby, and the pipeline activates it like any other release, which retires the release you're rolling back from. A retired release's hosts can't be made active again; the redeployment starts new ones.
Health and outages
Each host reports a heartbeat every 5 seconds. The vox_deployment health check shows the host's mode and when it last
reported: degraded after a failed report, unhealthy when it hasn't reported for longer than the liveness timeout. It
works while the database is unreachable, since it reads only what the host keeps in memory. The
Nexus admin shows it, but Nexus's own health reporting stops on a retiring host. To
follow every host of both releases from outside, read the activation's progress, which lists each host's mode and
heartbeat, see activate from the pipeline.
The deployment state is kept by an IVoxDeploymentOrchestrationStore. The default one keeps it in the Vox database
and uses the database's clock, so the hosts' clocks don't decide when a host is gone or an activation is late. An
application whose Vox database is too busy can register its own implementation, eg on another database.
When the deployment state can't be read, eg during a database outage, nothing stops: every host keeps accepting writes, an active host keeps processing, a host that doesn't process keeps not processing, and each applies what it missed, eg a retirement, as soon as it can read the state again. An activation can't complete meanwhile: it fails at its deadline, and doesn't complete when the database is back.
Settings
All in VoxOptions.Deployment:
| Setting | Default | |
|---|---|---|
DeploymentId | none | One deployment, always active, when unset |
BuildId | none | Diagnostics |
WorkerId | On Azure App Service WEBSITE_SITE_NAME and WEBSITE_INSTANCE_ID, otherwise the machine name | See worker ids |
ApiKey | none | The deployment endpoints refuse every request without it |
HeartbeatInterval | 5 s | |
LivenessTimeout | 60 s | At least a minute |
ActivationTimeout | 3 min | Longer than LivenessTimeout and HeartbeatInterval together |
MaxRetryDelay | 30 s | The longest wait between attempts to read the deployment state during an outage |