Deploy a Function
Ship a TypeScript function to Amba's edge runtime with `amba functions deploy` — versioned bundles, optional per-function rate limits, and rollback from the console.
amba functions deploy <file> bundles your handler and ships it to your
project's edge runtime. Each deploy is its own version; rollouts are
gradual with auto-rollback on a 5xx breach.
First deploy
Hit it:
Flags
--name <name>— function name (default: filename without extension). The function is served athttps://<project>.fn.amba.host/<name>.--dry-run— bundle and report size without uploading. Useful for CI to fail when a function approaches the size cap.--rate-limit-window <60s|5m|1h>— per-function rate-limit window.--rate-limit-max <int>— max requests per window.--rate-limit-key <user_id|ip>— bucket key for the rate limit (user_idreads the signed-in user from the session token;ipbuckets by client IP).
All three rate-limit flags must be set together, or all omitted (no rate limit). The edge runtime enforces the limit pre-dispatch — the handler never runs for rate-limited requests.
Rate limit example
That allows each signed-in user 5 requests per minute against
/checkout. The 6th in a window returns 429 Too Many Requests from
the edge without invoking the handler.
Reading secrets in production
process.env is populated from per-project secrets you set with the
CLI:
The handler reads them the same way it does locally:
Rollback
Every deploy is a new version with a unique id. The console's Rollouts view lists active versions in flight and offers a one-click rollback per version. The CLI also exposes:
If a deploy regresses, ramp the previous version back to 100% from the console Rollouts page.
Watching logs
--tail (alias --follow) streams new log events as they arrive.
--json emits one NDJSON event per line for piping into jq,
log-shipping tools, or local analysis.
Common pitfalls
- Bundle exceeds size cap —
amba functions deploy --dry-runto see the bundle report. The heaviest deps are usually large NPM packages pulled in transitively; check the report for the top size contributors and prune. - Missing secret at runtime — confirm you ran
amba secrets setfor the project you deployed to.amba secrets listshould show the name (values are never echoed). - First request slow — cold-starts hit after a long idle. The warm-path latency is much lower; in load tests, send a warming request before the burst.
Next
- Local dev — iterate with hot reload before deploy.
- CLI reference — all
amba functionssubcommands.