rayfin functions
Command reference for scaffolding, running, and deploying Rayfin Functions projects with functions init and related dev/up commands.
rayfin functions manages the TypeScript Functions package for a Rayfin project. In 1.36 it is a top-level GA command group; no RAYFIN_FEATURE_FLAGS=functions value is required.
Note
Functions are not available in every Fabric region or tenant.
rayfin functions init
npx rayfin functions init [directory] [--force] [--path <relative-path>]Scaffolds a Functions package, enables the service, installs dependencies, builds, generates types, and installs Rayfin agent files.
| Argument or option | Default | Description |
|---|---|---|
[directory] | . | Project root directory. Run from a directory that already contains rayfin/. |
--force | false | Overwrite an existing functions scaffold. Without it, existing function code is preserved and the command refreshes dependencies, build output, and generated types. |
--path <relative-path> | Auto-detected | Location for the functions package, relative to the project root. Overrides rayfin.yml and workspace detection, and is saved to services.functions.path. New in 1.36 |
Path selection order:
--path <relative-path>.- Existing
services.functions.pathinrayfin.yml. - An npm workspace package when one is detected.
rayfin/functions/.
Fresh or forced scaffolds create or overwrite these files under the resolved functions path:
package.jsonwith build and watch scripts.tsconfig.jsonwith a project reference torayfin/.host.jsonfor the local Azure Functions Core Tools host.local.settings.jsonfor local-only runtime settings.src/function_app.ts,src/types.ts, andsrc/secrets.generated.ts..vscode/settings.jsonand.vscode/launch.jsonwith Functions: Attach..gitignoreentries for local settings and build output.
Scaffolding installs dependencies from npm, so functions init requires network access.
Fresh or forced scaffolds write:
services:
functions:
enabled: true
path: rayfin/functions
auth:
type: application
buildCommand: npm run buildOn every run, fresh scaffold or not, the command installs dependencies, builds, and regenerates src/types.ts. Use it to refresh generated types without overwriting source; pass --force only when you want the template files replaced.
The scaffold pins @microsoft/fabric-user-data-functions to the exact version of the running CLI. Re-running without --force preserves the existing package version.
Because the Rayfin 2.0 CLI writes runtime metadata schema 3.0, a preserved older worker stops the type-generation step with an npm install @microsoft/fabric-user-data-functions@<cli-version> command to run in the functions package. Re-running functions init does not upgrade it. See Match the worker package to the CLI. Changed in 2.0
Fresh scaffolds from Rayfin 1.36.2 and later write host.json with extensionBundle.id: "Microsoft.Azure.Functions.ExtensionBundle.Preview" and extensionBundle.version: "[4.49.0, 5.0.0)". Existing apps are not migrated; update <services.functions.path>/host.json separately when upgrading. Changed in 1.36.2
rayfin dev functions apply
npx rayfin dev functions apply [--port <port>] [--inspect-port <port>] [--no-debug] [--no-emit-env] [--verbose] [--json] [-y]Verifies prerequisites, merges local settings, starts a local Azure Functions Core Tools host, starts watchers, and writes debugger configuration. Changed in 1.36
Rayfin 1.36.1 and later reduce Functions host restart output to Functions host restarted. and update an existing Functions: Attach debugger entry when the inspector port changes. Changed in 1.36.1
Before starting the host, the command checks that the installed @microsoft/fabric-user-data-functions can read runtime metadata schema 3.0 and stops with an npm install command when it cannot. Changed in 2.0 It also warns when the functions host.json still allows a Preview extension bundle older than 4.49.0, and when Core Tools exits with A window handle must be configured, it replaces the generic hint with the host.json fix. rayfin dev does the same when it starts the local Functions host. New in 2.0
| Option | Default | Description |
|---|---|---|
--port <port> | 7071 | Port for the local function host. Auto-shifts to the nearest free port if taken. |
--inspect-port <port> | 9229 | Port for the Node.js inspector when debugging is enabled. |
--no-debug | Debug on | Disable the Node.js inspector. |
--no-emit-env | Emit env | Skip auto-regenerating framework .env.local from rayfin/.env. |
--verbose | false | Show detailed diagnostic output. |
--json | false | Output JSON. |
-y, --yes | false | Run without interactive prompts. |
rayfin up functions deploy
npx rayfin up functions deploy [-v | --verbose] [--skip-build] [--json]Builds, packages, and deploys functions to an existing remote Rayfin item.
| Option | Default | Description |
|---|---|---|
-v, --verbose | false | Enable verbose output. |
--skip-build | false | Skip the build command and deploy existing content. |
--json | false | Output the result as JSON. |
This command uploads code only. It does not validate or apply services.functions.auth.type to the remote app; run a full npx rayfin up after changing Functions auth settings.
A 404 from this command usually means Functions are not enabled on the remote item — for example, because you ran rayfin functions init after the last full deploy. Run a full npx rayfin up once to apply services.functions from rayfin.yml, then retry. On a 404 the CLI prints that tip. New in 2.0
A functions project whose only function is a udf.authClaims provider can generate types and deploy. See Dynamic auth claims. New in 2.0
Related rayfin up flags
| Command or flag | Description |
|---|---|
npx rayfin up | Full app deploy. Deploys Functions when enabled and not excluded. Before changing anything remotely, it stops on an invalid custom audience. Changed in 2.0 |
npx rayfin up --exclude-services functions | Skip the functions build/package/deploy phase. Runtime settings remain unchanged. New in 1.36 |
npx rayfin init --services functions | Scaffold a new app with Functions enabled. New in 1.36 |
Errors
| Error text | Fix |
|---|---|
Not inside a Rayfin project (no `rayfin/` folder). Run this command from your project. | Run the command from a Rayfin project root or pass the project directory. |
Functions service is not enabled. Set 'services.functions.enabled: true' in rayfin.yml and re-run. | Run npx rayfin functions init or enable the service in rayfin.yml. |
Invalid services.functions.auth: authentication is required when Functions are enabled. Set services.functions.auth.type to "application". | Add services.functions.auth.type: application and run full npx rayfin up. |
No active deployment found. Run 'rayfin up' to deploy your Rayfin item first. | Deploy once before running the standalone local Functions host. |
Node.js >= 20 is required. Please upgrade your Node runtime and re-run. | Use Node.js 20 or later. |
Azure Functions Core Tools still not detected on PATH. Open a new shell so PATH updates take effect, then re-run `rayfin dev functions apply`. | Open a new shell and rerun after installing Core Tools. |
The installed @microsoft/fabric-user-data-functions@<version> ... but this CLI writes '3.0'. | Run the printed npm install @microsoft/fabric-user-data-functions@<cli-version> in the functions package. Changed in 2.0 |
<path>/host.json allows Functions extension bundles older than 4.49.0, ... | Warning. Set extensionBundle.version to [4.49.0, 5.0.0) in the functions host.json. New in 2.0 |
The Functions host could not sign in without a terminal window. ... | Set extensionBundle.version to [4.49.0, 5.0.0) in the named host.json, then retry. New in 2.0 |
Function '<name>': '<audience>' is not a valid custom audience. ... | Use an application ID (GUID) or an https:// or api:// resource URI without a scope, query, or wildcard. New in 2.0 |
Functions may not be enabled on the remote item. Run a full 'rayfin up' ... | Run a full npx rayfin up once, then retry rayfin up functions deploy. New in 2.0 |
In my Rayfin project, set up Functions with the Rayfin 2.0 CLI.
Run `npx rayfin functions init` unless a functions package already exists. If this is an npm-workspace layout, use `--path <relative-path>` or confirm the saved `services.functions.path`. Ensure `services.functions.enabled: true`, `services.functions.auth.type: application`, and `services.functions.buildCommand: npm run build` are present in rayfin/rayfin.yml, and that the functions package depends on @microsoft/fabric-user-data-functions at the CLI's exact version (2.0.0). Start local debugging with `npx rayfin dev functions apply`, and deploy with full `npx rayfin up` after auth changes or `npx rayfin up functions deploy` for a code-only update. Report exact errors if any command fails, and follow the fix the CLI prints for worker-version, host.json, or 404 errors.