rayfin functions
rayfin functions init scaffolds a serverless TypeScript Functions project under rayfin/functions/ that shares entity types with your Rayfin data model.
Note
The rayfin functions command group and rayfin up functions deploy are only
registered when services.functions.enabled: true in rayfin.yml (or
RAYFIN_FEATURE_FLAGS includes functions).
rayfin functions scaffolds and maintains a serverless Functions project that shares
entity types with your data model.
functions init
npx rayfin functions init [directory]Scaffolds rayfin/functions/ with:
package.jsonandtsconfig.json(wired as a TypeScript project reference to the parentrayfin/project, so Functions code canimport typeentity types directly fromrayfin/data/)host.jsonandlocal.settings.jsonsrc/function_app.tsandsrc/types.ts.vscode/settings.jsonand.vscode/launch.json(a Node debugger attach config).gitignore(excludeshost.json,local.settings.json, and build output)
On a fresh scaffold, it also enables services.functions.enabled: true in rayfin.yml. On
every run — fresh scaffold or not — it installs dependencies, builds, and regenerates
rayfin/functions/src/types.ts from your function source files. Regeneration is a one-shot
pass, not a background watcher; re-run functions init (without --force) any time you
want to refresh types.ts without touching your scaffolded code.
| Flag | Description |
|---|---|
--force | Overwrite an existing rayfin/functions/ scaffold. Without it, an existing scaffold is left untouched and the command only reinstalls dependencies, rebuilds, and regenerates types.ts. |
Note
Scaffolding installs @microsoft/fabric-user-data-functions from the npm registry, so
functions init requires network access.
Deploying
rayfin up functions deploy (experimental)
builds, packages, and deploys Functions to the remote Rayfin item. A plain rayfin up also
deploys Functions automatically when the service is enabled.
Enable Functions in my Rayfin project (set services.functions.enabled: true if not already),
then run `npx rayfin functions init` to scaffold rayfin/functions/. Show me the generated
src/function_app.ts and explain how to add a new HTTP-triggered function that reads from one
of my existing entities.