---
title: "rayfin functions"
description: "rayfin functions init scaffolds a serverless TypeScript Functions project under rayfin/functions/ that shares entity types with your Rayfin data model."
url: https://rayfin.ai/docs/reference/cli/functions
markdown_url: https://rayfin.ai/docs/reference/cli/functions.md
section: reference
product: Rayfin
sdk_version: 1.34.0
cli_version: 1.33.2
last_updated: 2026-08-23T01:28:43-07:00
source: reference/cli/functions.mdx
---

# 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` [#functions-init]

```bash
npx rayfin functions init [directory]
```

Scaffolds `rayfin/functions/` with:

* `package.json` and `tsconfig.json` (wired as a TypeScript project reference to the
  parent `rayfin/` project, so Functions code can `import type` entity types directly from
  `rayfin/data/`)
* `host.json` and `local.settings.json`
* `src/function_app.ts` and `src/types.ts`
* `.vscode/settings.json` and `.vscode/launch.json` (a Node debugger attach config)
* `.gitignore` (excludes `host.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 [#deploying]

[`rayfin up functions deploy`](/docs/reference/cli/up#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.

```prompt title="Scaffold a Functions project"
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.
```
