@microsoft/rayfin-guide 1.36.0-alpha.1593 → 1.36.0-alpha.1620

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/assets/docs/{experimental/cli → cli}/connectors/add.md +2 -0
  2. package/assets/docs/{experimental/cli → cli}/connectors/category-a-entities.md +1 -1
  3. package/assets/docs/{experimental/cli → cli}/connectors/category-b-function-bridge.md +38 -12
  4. package/assets/docs/cli/connectors/eventhouse.md +21 -0
  5. package/assets/docs/{experimental/cli → cli}/connectors/index.md +7 -22
  6. package/assets/docs/{experimental/cli → cli}/connectors/invoke.md +4 -0
  7. package/assets/docs/{experimental/cli → cli}/connectors/search.md +4 -2
  8. package/assets/docs/cli/environment-variables.md +2 -2
  9. package/assets/docs/cli/functions/deploy.md +38 -0
  10. package/assets/docs/cli/functions/dev-apply.md +62 -0
  11. package/assets/docs/cli/functions/index.md +41 -0
  12. package/assets/docs/cli/functions/init.md +62 -0
  13. package/assets/docs/cli/index.md +35 -1
  14. package/assets/docs/cli/secrets.md +97 -122
  15. package/assets/docs/cli/templates.md +7 -0
  16. package/assets/docs/functions/connections/add-ado.md +39 -0
  17. package/assets/docs/functions/connections/add-azure-resource.md +171 -0
  18. package/assets/docs/functions/connections/add-fabric-resource.md +186 -0
  19. package/assets/docs/functions/connections/add-foundry.md +46 -0
  20. package/assets/docs/functions/connections/add-work-iq.md +39 -0
  21. package/assets/docs/functions/connections/get-fabric-info.md +159 -0
  22. package/assets/docs/functions/connections/index.md +89 -0
  23. package/assets/docs/functions/index.md +91 -0
  24. package/assets/docs/functions/invoking-from-frontend.md +94 -0
  25. package/assets/docs/functions/secrets.md +70 -0
  26. package/assets/docs/functions/typegen.md +44 -0
  27. package/assets/docs/functions/writing-functions.md +140 -0
  28. package/assets/docs/getting-started/project-structure.md +91 -2
  29. package/package.json +1 -1
  30. /package/assets/docs/{experimental/cli → cli}/connectors/inspect.md +0 -0
@@ -8,6 +8,8 @@ sidebar_position: 2
8
8
  npx rayfin connector add --type <type> --workspace-id <ws-id> --item-id <item-id> [--name <name>] [--operations <ops>]
9
9
  ```
10
10
 
11
+ > **`kusto` authoring is held in this release**, so `connector add --type kusto` refuses before writing anything. Kusto examples below describe the authoring path for when it ships. See [Connectors](./index.md) for what a project that already declares Kusto can still do.
12
+
11
13
  `connector add` declares a connector in `rayfin/rayfin.yml` and scaffolds its supporting files.
12
14
 
13
15
  The CLI verifies the Fabric item, derives a connector `name` from the item's display name (override with `--name`), writes the entry to `rayfin.yml`, and scaffolds `rayfin/connectors/<name>/schema.ts`. For Category A connectors it also runs schema discovery and writes `rayfin/connectors/<name>/metadata.json` so a subset of entities can be generated later.
@@ -1,5 +1,5 @@
1
1
  ---
2
- sidebar_position: 8
2
+ sidebar_position: 5
3
3
  ---
4
4
 
5
5
  # Category A — GraphQL entity connectors
@@ -1,10 +1,14 @@
1
1
  ---
2
- sidebar_position: 7
2
+ sidebar_position: 6
3
3
  ---
4
4
 
5
5
  # Category B — function-bridge connectors
6
6
 
7
- Reference for `kusto` (Fabric KQL Database) and `fabric-semanticmodel` (Power BI semantic model).
7
+ Reference for `fabric-semanticmodel` (Power BI semantic model) and the experimental `kusto` (the **Eventhouse** connector — a Fabric Eventhouse KQL Database).
8
+ Eventhouse is the Fabric product name; `kusto` is the type id you pass to `--type`, and KQL is its query language.
9
+
10
+ > **`kusto` authoring is held in this release**, so `connector add --type kusto` refuses and search omits KQL databases. Everything below about `kusto` stays accurate for a project that **already declares** one — which still validates, deploys and invokes — and describes the authoring path for when it ships. Only `fabric-semanticmodel` can be added today. See [Connectors](./index.md).
11
+
8
12
  A Category B connector is a named-operation surface backed by a small, platform-owned function (UDF).
9
13
  The Builder never writes or sees the function code.
10
14
 
@@ -17,8 +21,8 @@ For the entity-generating types (`fabric-sqlanalytics`, `fabric-warehouse`, `fab
17
21
 
18
22
  | Type | Operations | Query language | Auth |
19
23
  | --- | --- | --- | --- |
20
- | `kusto` | `executeQuery`, `executeCommand` | KQL | `delegated` only |
21
24
  | `fabric-semanticmodel` | `executeQuery` | DAX | `delegated` only |
25
+ | `kusto` (**experimental**) | `executeQuery`, `executeCommand` | KQL | `delegated` only |
22
26
 
23
27
  Both are pinned to an adapter version (`version: '1'` today).
24
28
  Delegated authentication runs every call as the signed-in user through the on-behalf-of flow.
@@ -78,7 +82,7 @@ export const connectorConfig = {
78
82
  } as const satisfies ConnectorConfig;
79
83
  ```
80
84
 
81
- ### Kusto bakes cluster routing into the generated file
85
+ ### The Eventhouse scaffold bakes cluster routing into the generated file
82
86
 
83
87
  `connector add --type kusto` resolves the KQL Database's cluster query endpoint and database name from `(workspaceId, itemId)` at add time and writes both into the generated `connectorConfig`:
84
88
 
@@ -100,11 +104,11 @@ Three names appear here and nowhere else:
100
104
  - `databaseName` — the resolved KQL database name.
101
105
  - `KustoConnectorConfig` — the Kusto-specific config type these two keys satisfy, exported from `@microsoft/rayfin-connector-kusto` rather than `@microsoft/rayfin-connectors`.
102
106
 
103
- These keys live only in the file the Kusto scaffold writes.
107
+ These keys live only in the file the Eventhouse scaffold writes.
104
108
  They are **not** part of the shared `rayfin.yml` schema — never write a cluster URI or database name into `rayfin.yml`, and never send either value from app code.
105
109
  If the resolved values look wrong, re-add the connector rather than editing the generated file; the values come from Fabric, not from anything you can fix by hand.
106
110
 
107
- The Kusto scaffold imports both its marker and `KustoConnectorConfig` from `@microsoft/rayfin-connector-kusto`, so it does not import `@microsoft/rayfin-connectors` at all.
111
+ The Eventhouse scaffold imports both its marker and `KustoConnectorConfig` from `@microsoft/rayfin-connector-kusto`, so it does not import `@microsoft/rayfin-connectors` at all.
108
112
 
109
113
  ## Install the packages the generated file imports
110
114
 
@@ -113,7 +117,7 @@ The Kusto scaffold imports both its marker and `KustoConnectorConfig` from `@mic
113
117
  ```bash
114
118
  # Shape only. Use the version connector add printed, not this one.
115
119
 
116
- # kusto — marker and config type both come from this one package
120
+ # kusto (experimental) — marker and config type both come from this one package
117
121
  npm install @microsoft/rayfin-connector-kusto@1.35.0-alpha
118
122
 
119
123
  # fabric-semanticmodel
@@ -136,7 +140,7 @@ This is not optional: the runtime is what injects the generated routing and deco
136
140
  Key the runtime map by the same connector name, and call the factory once per connector:
137
141
 
138
142
  ```ts
139
- import { ConnectorsRayfinClient } from '@microsoft/rayfin-client/experimental';
143
+ import { ConnectorsRayfinClient } from '@microsoft/rayfin-client';
140
144
  import { kusto } from '@microsoft/rayfin-connector-kusto';
141
145
  import { fabricSemanticModel } from '@microsoft/rayfin-connector-fabric-semanticmodel';
142
146
  import {
@@ -174,11 +178,11 @@ const client = new ConnectorsRayfinClient<
174
178
  );
175
179
  ```
176
180
 
177
- `ConnectorsRayfinClient` is experimental — import it only from the `@microsoft/rayfin-client/experimental` subpath, never the stable `@microsoft/rayfin-client` entry.
181
+ `ConnectorsRayfinClient` is stable — import it from the main `@microsoft/rayfin-client` entry.
178
182
 
179
183
  The connector key must be identical in four places: the `name` in `rayfin.yml`, the property in `AppConnectorsSchema`, the property in the `connectors` option, and the property in the runtime map.
180
184
 
181
- ## Calling a Kusto connector
185
+ ## Calling an Eventhouse connector
182
186
 
183
187
  Correlation ids are not part of the response body — the connector function relays the Kusto bytes untouched — so generate the `clientRequestId` yourself and pass the same value to both `executeQuery` and `toQueryResult`:
184
188
 
@@ -208,6 +212,28 @@ Successful results contain `tables` plus the `clientRequestId` you passed in (em
208
212
  Each table contains named typed `columns` and row-major `rows`.
209
213
  Error results contain `error.message` and an optional `error.code`.
210
214
 
215
+ ### Building queries safely
216
+
217
+ `executeQuery` takes its KQL in `query` and `executeCommand` takes its command in `command`; neither operation binds parameters — `ExecuteQueryInput` exposes only `query` and `clientRequestId`, and `ExecuteCommandInput` only `command` and `clientRequestId`. Every user value you place in that text runs as KQL, so treat all user input as unsafe and never interpolate it raw.
218
+
219
+ - **Identifiers** (table, column, function names): map the user's choice through a fixed allow-list to a known-good constant. Never build an identifier from user text.
220
+ - **Values**: serialize each as a typed KQL literal. Validate numbers (for example with `Number.isFinite`), parse datetimes to ISO 8601 and wrap them in `todatetime(...)`, and for strings escape `\` and `"` and reject control characters. This repo ships no KQL encoder; generic SQL or JSON escaping does not make KQL safe.
221
+
222
+ ```ts
223
+ const TABLES = { events: 'Events', logs: 'Logs' } as const;
224
+ const table = TABLES[userTable];
225
+ if (!table) throw new Error('unknown table');
226
+
227
+ // Typed KQL string literal: escape backslash and double-quote, reject control chars.
228
+ function kqlString(value: string): string {
229
+ if (/[\u0000-\u001F]/.test(value)) throw new Error('control character in value');
230
+ return '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
231
+ }
232
+ // kqlString('contoso "42"') -> "contoso \"42\""
233
+
234
+ const query = `${table} | where DeviceId == ${kqlString(userDeviceId)} | take 200`;
235
+ ```
236
+
211
237
  ### Management commands
212
238
 
213
239
  `executeCommand` runs a Kusto management (control) command — the command text starts with a leading dot.
@@ -240,10 +266,10 @@ Run `rayfin docs search "resultSetRowCountLimit"` for version-locked details, si
240
266
  `rayfin connector invoke <name> <operation>` is the loop for Category B.
241
267
  See [`connector invoke`](./invoke.md) for payload input, transports, token handling, and the output contract.
242
268
 
243
- - `connector inspect` supports `fabric-semanticmodel` but **not** `kusto` — a `kusto` connector errors with `Unsupported connector type: kusto`.
269
+ - `connector inspect` supports `fabric-semanticmodel` but **not** experimental `kusto` — a `kusto` connector errors with `Unsupported connector type: kusto`.
244
270
  There is no ad-hoc query path for Kusto connectors today.
245
271
  - `connector invoke` on `fabric-semanticmodel` calls Fabric/Power BI directly under the developer's identity, so it works with or without `rayfin up`.
246
- Every other type, `kusto` included, POSTs to the deployed item and requires a prior `rayfin up`.
272
+ Every other type, including experimental `kusto`, POSTs to the deployed item and requires a prior `rayfin up`.
247
273
  - `connector invoke` on `fabric-semanticmodel` returns an already-normalized result, because that connector normalizes inside its `invoke` middleware.
248
274
  Do not apply `toQueryResult` to it again.
249
275
  - A resolved `connector invoke` call is not automatically a success.
@@ -0,0 +1,21 @@
1
+ ---
2
+ sidebar_position: 9
3
+ ---
4
+
5
+ # Eventhouse (`kusto`) usage guide
6
+
7
+ > **Moved.** This usage guide now ships **inside the connector package**,
8
+ > version-locked to the `kusto` connector the Builder actually installed — so the
9
+ > streaming model, KQL shaping, safe query construction, and result handling can
10
+ > never drift from the CLI. It is fetched on demand with `packageVersion`
11
+ > provenance.
12
+ >
13
+ > Read it from `@microsoft/rayfin-connector-kusto`:
14
+ >
15
+ > - MCP: `search_docs` / `discover_packages`
16
+ > - CLI: `rayfin docs search "<term>"` (module `rayfin-connector-kusto`)
17
+ > - Source: `@microsoft/rayfin-connector-kusto/assets/docs/`
18
+ >
19
+ > The shared function-bridge mechanics — `connector add`, the generated
20
+ > `rayfin.yml` and `schema.ts`, and the `client.connectors.<name>` call — stay in
21
+ > the [Category B guide](./category-b-function-bridge.md).
@@ -6,25 +6,9 @@ sidebar_position: 6
6
6
 
7
7
  Connectors let a Rayfin app read from — and, for some types, write to — Microsoft Fabric data sources: warehouses, SQL databases, Lakehouse SQL analytics endpoints, semantic models, and KQL databases.
8
8
 
9
- ## Prerequisite — enabling the `connector` command group
9
+ The `connector` command group is always available.
10
10
 
11
- Connectors are behind a feature flag, so `rayfin connector ...` is only registered when the project opts in. Prefer the declarative setting in `rayfin/rayfin.yml`:
12
-
13
- ```yaml
14
- services:
15
- connectors:
16
- enabled: true
17
- ```
18
-
19
- With that setting present the command group is available from the very first `connector add`, with nothing to configure in the shell — the path generated apps and agents should use.
20
-
21
- The flag also activates automatically once `rayfin.yml` has a `connectors:` block (written by `connector add`), and it can still be turned on for a single command with the environment variable:
22
-
23
- ```bash
24
- RAYFIN_FEATURE_FLAGS=connectors npx rayfin connector search --help
25
- ```
26
-
27
- Without any of the three the commands do not exist and the CLI reports an unknown command.
11
+ > **`kusto` authoring is held in this release.** `connector types` and `connector search` omit it, and `connector add --type kusto` refuses it. A project that **already declares** a Kusto connector is unaffected: it still validates, deploys through `rayfin up`, and answers `connector invoke`. Kusto material in these docs describes that preserved runtime contract and the authoring path for when it ships.
28
12
 
29
13
  Each command has its own reference page:
30
14
 
@@ -36,7 +20,8 @@ Each command has its own reference page:
36
20
  Each category has its own contract page — read the one that matches your connector type, not both:
37
21
 
38
22
  - [Category A — GraphQL entity connectors](./category-a-entities.md) — now **package-owned**; the full reference (entity generation, `@role` policies, the aggregate schema, and the per-dialect read/write matrix) ships in `@microsoft/rayfin-connector-fabric-graphql` (`rayfin docs search` / `search_docs`).
39
- - [Category B — function-bridge connectors](./category-b-function-bridge.md) — the `kusto` and `fabric-semanticmodel` contract, including the Kusto cluster routing baked into the generated `schema.ts`.
23
+ - [Category B — function-bridge connectors](./category-b-function-bridge.md) — the `fabric-semanticmodel` and experimental `kusto` contract, including the Kusto cluster routing baked into the generated `schema.ts`.
24
+ - [Eventhouse (`kusto`) usage guide](./eventhouse.md) — the experimental `kusto` supplement, now **package-owned**; when to reach for the type, its streaming model, shaping KQL, safe query construction, and reading results all ship in `@microsoft/rayfin-connector-kusto` (`rayfin docs search` / `search_docs`).
40
25
 
41
26
  A typical loop is search → add → inspect (Category A) or search → add → invoke (Category B).
42
27
 
@@ -46,13 +31,13 @@ The commands available to a connector, and the code you write against it, depend
46
31
 
47
32
  | | Category A — GraphQL entity connectors | Category B — function-bridge connectors |
48
33
  | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
49
- | **Types** | `fabric-sqlanalytics`, `fabric-warehouse`, `fabric-sqldatabase` | `kusto`, `fabric-semanticmodel` |
50
- | **App surface** | Generated entity files with typed CRUD through the data client | A single `executeQuery` operation carrying a raw query |
34
+ | **Types** | `fabric-sqlanalytics`, `fabric-warehouse`, `fabric-sqldatabase`, `fabric-graphql` | `fabric-semanticmodel`; `kusto` (**experimental**) |
35
+ | **App surface** | Generated entity files with typed CRUD through the data client | Named operations carrying raw queries |
51
36
  | **Operations** | `read` only for `fabric-sqlanalytics` (Lakehouse SQL endpoints are read-only); `read`, `create`, `update`, `delete` for `fabric-warehouse` and `fabric-sqldatabase` (narrowable) | `executeQuery` only |
52
37
  | **Auth** | `delegated` or configured per project | Must be `delegated` |
53
38
  | **Entity files and `@role` policies** | Yes | No |
54
39
  | **`metadata.json` entities** | Yes | No |
55
- | **`connector inspect`** | Supported | `fabric-semanticmodel` only — `kusto` is not supported |
40
+ | **`connector inspect`** | Supported | `fabric-semanticmodel` only — experimental `kusto` is not supported |
56
41
  | **`connector invoke`** | Rarely needed | The main way to exercise the connector |
57
42
 
58
43
  Category B connectors are pinned to an adapter version and expose no GraphQL entities, so there is nothing to generate and no row-level security to author.
@@ -32,6 +32,10 @@ Two transports, chosen by connector type:
32
32
  - **`fabric-semanticmodel`** — the CLI calls Fabric/Power BI **directly under the developer's own identity**, so this works whether or not `npx rayfin up` has been run. It requires `workspaceId` **and** `itemId` under the connector's `config:` block; without both, it fails up front rather than falling through to the deployed transport. The Power BI scope and audience are derived from the configured Fabric API base URL, so an INT ring mints an INT-audience token.
33
33
  - **Every other type, including `kusto`** — POSTs to the deployed item at `<remote-endpoint>/__private/connectors/<name>/invoke`, so it requires a prior `npx rayfin up`.
34
34
 
35
+ > `kusto` authoring is held in this release, but invocation is deliberately preserved: a project that already declares a Kusto connector can still invoke it. Only `connector add`, `types` and `search` withdraw the type. See [Connectors](./index.md).
36
+
37
+ `--transport deployed` overrides the type-based choice and forces the deployed route. That route authenticates the **app**, not the developer, so it needs an app-session token in `RAYFIN_TOKEN`; `npx rayfin login` cannot mint one.
38
+
35
39
  ## Token handling (semantic model path)
36
40
 
37
41
  `npx rayfin login` only consents to the Fabric scope, not the Power BI scope this path needs. Consequences:
@@ -8,7 +8,9 @@ sidebar_position: 1
8
8
  npx rayfin connector search [query] [--workspace-id <id> --type <types> | --all-workspaces --type <types>] [--limit <n>] [--json]
9
9
  ```
10
10
 
11
- `connector search` finds Fabric data sources warehouses, SQL databases, Lakehouses, semantic models, and KQL databases that the signed-in identity can add as connectors, before you know exact workspace or item IDs.
11
+ > **`kusto` authoring is held in this release**, so search does not return KQL databases and `--type kusto` is not accepted. Search exists to feed `connector add`, which would refuse the type surfacing a source the Builder could not then attach. See [Connectors](./index.md).
12
+
13
+ `connector search` finds Fabric data sources — warehouses, SQL databases, Lakehouses, and semantic models — that the signed-in identity can add as connectors, before you know exact workspace or item IDs.
12
14
 
13
15
  Use it to find candidates for [`connector add`](./add.md). It never touches app data itself.
14
16
 
@@ -38,7 +40,7 @@ Only one of `--workspace-id` and `--all-workspaces` may be given. Outside a Rayf
38
40
 
39
41
  Duplicate-looking entries — for example a SQL Database and its SQL-analytics-endpoint twin sharing a workspace and display name — are grouped visually next to each other in interactive and plain output only. They are never deduplicated, and `--json` always returns the canonical, ungrouped order.
40
42
 
41
- The SQL-endpoint-permissions note ("Schema discovery for SQL-based connectors requires SQL endpoint permissions") only prints when at least one result is a SQL-dialect connector type — never for a semantic-model-only or Kusto-only result set.
43
+ The SQL-endpoint-permissions note ("Schema discovery for SQL-based connectors requires SQL endpoint permissions") only prints when at least one result is a SQL-dialect connector type — never for a semantic-model-only result set. (It would also not print for a Kusto-only set, once Kusto authoring ships.)
42
44
 
43
45
  ## Examples
44
46
 
@@ -189,7 +189,7 @@ These variables are read from the shell environment and are never written to fil
189
189
  | `RAYFIN_WORKSPACE_ID` | Fabric workspace ID for non-interactive setup. Used with `RAYFIN_TOKEN`. |
190
190
  | `RAYFIN_TENANT_ID` | Entra ID tenant used by `rayfin up` for portal URLs and the `ctid` query parameter. Equivalent to the `-t, --tenant <id>` flag (precedence: flag > env var > signed-in tenant). |
191
191
  | `RAYFIN_ENCRYPTION_FALLBACK_ENABLED` | Set to `true` to allow plaintext token cache on systems without OS credential storage. Development only. |
192
- | `RAYFIN_FEATURE_FLAGS` | Comma-separated list of experimental feature names to enable (case-insensitive). Recognized values include `docker-local-dev`, `functions`, and `postgresql`. |
192
+ | `RAYFIN_FEATURE_FLAGS` | Comma-separated list of experimental feature names to enable (case-insensitive). Recognized public values include `docker-local-dev`, `postgresql`, and `storage`. |
193
193
  | `RAYFIN_WEBSERVICE_IMAGE_NAME` | **Experimental.** Override the webservice container image used by `rayfin dev --provider docker` and Docker Compose. Defaults to `ghcr.io/microsoft/project-rayfin/webservice:cli-<version>`. |
194
194
  | `RAYFIN_APPINSIGHTS_CONNECTION_STRING` | Override the telemetry endpoint for the CLI and VS Code extension. |
195
195
  | `RAYFIN_TELEMETRY_ENV` | Override the CLI and `create-rayfin` telemetry environment label. Values are trimmed and lowercased. Known labels include `github-actions`, `azure-pipelines`, `gitlab-ci`, `jenkins`, `codespaces`, `devcontainer`, `local`, and `other`; custom labels may contain 1–64 ASCII letters, digits, hyphens, or underscores. Invalid non-empty values map to `other`, while an empty value uses automatic detection. Do not include identifying or sensitive values. |
@@ -199,8 +199,8 @@ These variables are read from the shell environment and are never written to fil
199
199
  | Flag | Effect |
200
200
  | --- | --- |
201
201
  | `docker-local-dev` | Allows `rayfin dev --provider docker` and the Docker maintenance commands. Bare `rayfin dev` remains available without this flag and defaults to Fabric. |
202
- | `functions` | Exposes Functions service prompts during `rayfin init`. |
203
202
  | `postgresql` | Adds PostgreSQL as a selectable dialect during `rayfin init` and `rayfin init` with bundled templates. |
203
+ | `storage` | Enables the preview Storage service when declared in `rayfin.yml` or opted in from the shell. |
204
204
 
205
205
  ## File locations
206
206
 
@@ -0,0 +1,38 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # up functions deploy
6
+
7
+ Build, package, and deploy your functions to the remote Rayfin item.
8
+
9
+ ```bash
10
+ npx rayfin up functions deploy [-v | --verbose] [--skip-build] [--json]
11
+ ```
12
+
13
+ ## When to use it
14
+
15
+ `npx rayfin up` already deploys functions as part of a full deployment. Use `up functions deploy` when you want to run **only** the functions step — for example to retry after a functions deploy failed, or to push a functions-only change without redeploying the rest of the app.
16
+
17
+ ## Prerequisites
18
+
19
+ Run `npx rayfin up` at least once first. This command deploys to an existing remote item, so a remote endpoint must already exist. If there is no active deployment, run a full `npx rayfin up`.
20
+
21
+ ## Options
22
+
23
+ | Option | Description |
24
+ | --------------- | -------------------------------------------------------------- |
25
+ | `-v, --verbose` | Print detailed build and deploy output. |
26
+ | `--skip-build` | Deploy the already-built output without rebuilding first. |
27
+ | `--json` | Emit machine-readable JSON instead of human-readable progress. |
28
+
29
+ ## What it does
30
+
31
+ 1. Builds and packages the functions project (unless `--skip-build`).
32
+ 2. Deploys the package to the remote Rayfin item resolved from your active deployment.
33
+
34
+ ## Related
35
+
36
+ - [`functions init`](./init.md) — scaffold and enable functions.
37
+ - [`dev functions apply`](./dev-apply.md) — run and debug functions locally before deploying.
38
+ - [Managing Secrets](../secrets.md) — push secrets that deployed functions read via `ctx.getSecret`.
@@ -0,0 +1,62 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # dev functions apply
6
+
7
+ Start the local Rayfin functions runtime against your active deployment, with a live typegen watcher and debugger support. This is the command you run while developing and debugging functions.
8
+
9
+ ```bash
10
+ npx rayfin dev functions apply [--port <port>] [--inspect-port <port>] [--no-debug] [--no-emit-env]
11
+ ```
12
+
13
+ ## Prerequisites
14
+
15
+ - **Functions must be enabled** — run [`npx rayfin functions init`](./init.md) first so `services.functions.enabled` is set in `rayfin.yml`.
16
+ - **Node.js ≥ 20** and **Azure Functions Core Tools** must be installed. The command verifies these and, with your consent, installs Core Tools if missing.
17
+ - **An active deployment** — run `npx rayfin up` at least once so a remote endpoint and publishable key exist to resolve against.
18
+
19
+ ## Options
20
+
21
+ | Option | Default | Description |
22
+ | ----------------------- | ------- | ----------------------------------------------------------------------------- |
23
+ | `--port <port>` | `7071` | Port for the local function host. Auto-shifts to the next free port if taken. |
24
+ | `--inspect-port <port>` | `9229` | Port for the Node inspector (debugger). |
25
+ | `--no-debug` | off | Disable the inspector / attach support. |
26
+ | `--no-emit-env` | off | Skip regenerating the framework `.env.local`. |
27
+
28
+ ## What it does
29
+
30
+ 1. Gates on `services.functions.enabled` and checks prerequisites (Node, Core Tools).
31
+ 2. Resolves the active deployment and publishable key.
32
+ 3. Writes `rayfin/functions/local.settings.json` (environment, API URL, publishable key, workspace/item ids, inspector flag when debugging).
33
+ 4. Upserts `RAYFIN_PUBLIC_FUNCTIONS_URL` into `rayfin/.env` and regenerates the framework `.env.local` (unless `--no-emit-env`).
34
+ 5. Preserves the existing same-origin adapter in bundled Vite templates.
35
+ For recognized older or custom Vite clients, the first run patches `functionsBaseUrl` to read the generated URL only during development.
36
+ 6. Builds the functions project, runs a one-shot typegen, then starts a visible **typegen watcher** (`[typegen]` prefix) that keeps `src/types.ts` in sync as you edit `function_app.ts`.
37
+ 7. Starts `func start` in the foreground and writes a `.vscode/launch.json` **"Functions: Attach"** configuration for debugging.
38
+
39
+ Press `Ctrl+C` to stop the host and watcher.
40
+ This command does not start the frontend.
41
+ Run the Vite frontend separately to invoke local functions through `/.rayfin/api/<name>`, or use `npx rayfin dev` to start both together.
42
+ If the local Functions host is unavailable, the Vite adapter returns HTTP 502 instead of invoking deployed function code.
43
+
44
+ ## Debugging
45
+
46
+ With debugging enabled (default), attach your debugger to the inspector port (`9229` by default) using the generated **"Functions: Attach"** launch configuration in VS Code. Pass `--no-debug` to run without the inspector.
47
+
48
+ ## Secrets in local development
49
+
50
+ Locally there is no deployed secret bag, so `ctx.getSecret(name)` falls back to `process.env`. To provide a secret, add it under `Values` in `rayfin/functions/local.settings.json`; the functions host loads those entries into `process.env`. See [Managing Secrets](../secrets.md#using-secrets-in-local-development).
51
+
52
+ ## Next step
53
+
54
+ When your functions are working locally, deploy them:
55
+
56
+ ```bash
57
+ npx rayfin up # deploys everything, including functions
58
+ # or, to re-run only functions:
59
+ npx rayfin up functions deploy
60
+ ```
61
+
62
+ See [`up functions deploy`](./deploy.md).
@@ -0,0 +1,41 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Functions
6
+
7
+ Rayfin functions are server-side user-defined functions (UDFs) that run in the Fabric runtime and are invocable from your frontend through `RayfinClient`. Use them for logic that must run on the backend — secrets and API keys, privileged data access, server-side validation, and anything that should not be exposed or tampered with in client code.
8
+
9
+ The functions project lives at `rayfin/functions/` and is enabled by the `services.functions.enabled` flag in `rayfin.yml` (set for you the first time you run [`functions init`](./init.md)).
10
+
11
+ Each command has its own reference page:
12
+
13
+ - [`functions init`](./init.md) — scaffold `rayfin/functions/`, install dependencies, and seed `types.ts`.
14
+ - [`dev functions apply`](./dev-apply.md) — run the local function host with a live typegen watcher for development and debugging.
15
+ - [`up functions deploy`](./deploy.md) — build, package, and deploy functions to the remote Rayfin item.
16
+
17
+ ## The development loop
18
+
19
+ ```text
20
+ functions init → write UDFs in src/function_app.ts → dev functions apply → up
21
+ (scaffold) (typegen keeps types.ts fresh) (local host+debug) (deploy)
22
+ ```
23
+
24
+ 1. **`npx rayfin functions init`** scaffolds the project, installs dependencies, runs a one-shot typegen, and enables the service in `rayfin.yml`.
25
+ 2. **Write functions** with `udf.func(name, handler, [])` in `rayfin/functions/src/function_app.ts`. The CLI parses these calls and generates `rayfin/functions/src/types.ts` (the `AppFunctionsSchema`) — never hand-edit it.
26
+ 3. **`npx rayfin dev functions apply`** starts the local Azure Functions host, keeps a visible `[typegen]` watcher running so `types.ts` stays in sync as you edit, and publishes its URL for local frontend routing.
27
+ Bundled Vite apps use that URL through the same-origin `/.rayfin/api/<name>` route when you run the frontend separately.
28
+ 4. **`npx rayfin up`** deploys everything, including functions. To re-run only the functions step, use [`npx rayfin up functions deploy`](./deploy.md).
29
+
30
+ > **`npx rayfin dev` vs. `npx rayfin dev functions apply`:** Prefer `npx rayfin dev` for normal local development because it runs your functions alongside the frontend and backend. Use `npx rayfin dev functions apply` when you want to run **only** the functions host — with its typegen watcher and debugger — without starting the frontend/static app.
31
+
32
+ ## Where functions state lives
33
+
34
+ - `rayfin/functions/src/function_app.ts` — where you register UDFs with `udf.func()`.
35
+ - `rayfin/functions/src/types.ts` — auto-generated `AppFunctionsSchema`; regenerated by `functions init` (one-shot) and by the watcher inside `dev functions apply`.
36
+ - `rayfin/functions/{package.json,host.json,tsconfig.json,local.settings.json}` — the functions app manifest, host config, TypeScript project references, and local settings.
37
+ - `rayfin.yml` — the `services.functions` block (`enabled`, `buildCommand`).
38
+
39
+ ## Secrets
40
+
41
+ Functions read secrets at runtime with `ctx.getSecret(name)`, backed by the host secret bag with a `process.env` fallback. Manage remote secrets with `npx rayfin secret set` — or bulk-set them from a file with `npx rayfin secret set --env-file` — see [Managing Secrets](../secrets.md).
@@ -0,0 +1,62 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # functions init
6
+
7
+ Scaffold a Rayfin functions project under `rayfin/functions/`, enable the functions service, install dependencies, build, and generate the initial types.
8
+
9
+ ```bash
10
+ npx rayfin functions init [directory] [--force]
11
+ ```
12
+
13
+ ## Prerequisites
14
+
15
+ Run this from a directory that already contains a `rayfin/` project (i.e. you have already run `npx rayfin init`). If `rayfin/` is missing, the command errors and asks you to initialize the app first.
16
+
17
+ ## Arguments and options
18
+
19
+ | Name | Description |
20
+ | ------------- | ---------------------------------------------------------------------------------------------------- |
21
+ | `[directory]` | Project directory to initialize in. Defaults to the current directory (`.`). |
22
+ | `--force` | Overwrite an existing `rayfin/functions/` scaffold. Without it, existing function code is preserved. |
23
+
24
+ ## What it does
25
+
26
+ 1. **Scaffolds** `rayfin/functions/` with a starter function app, `host.json`, `tsconfig.json`, `package.json`, and `local.settings.json`.
27
+ 2. **Enables the service** in `rayfin.yml` by setting `services.functions.enabled: true` and `services.functions.buildCommand: 'npm run build'`.
28
+ 3. **Installs dependencies** for the functions project.
29
+ 4. **Builds** the project.
30
+ 5. **Generates types** — runs a one-shot typegen to produce `rayfin/functions/src/types.ts` (the `AppFunctionsSchema`).
31
+ 6. **Installs AI agent files** so assistants understand the functions surface.
32
+
33
+ ## Scaffolded structure
34
+
35
+ ```text
36
+ rayfin/
37
+ functions/
38
+ src/
39
+ function_app.ts # register UDFs here with udf.func(...)
40
+ types.ts # generated AppFunctionsSchema — do not hand-edit
41
+ host.json
42
+ local.settings.json
43
+ package.json
44
+ tsconfig.json
45
+ ```
46
+
47
+ ## Re-running
48
+
49
+ `functions init` is safe to re-run:
50
+
51
+ - **Without `--force`** on an existing project, it preserves your `function_app.ts` and only refreshes dependencies, build, and generated types.
52
+ - **With `--force`**, it overwrites the scaffold (a warning is shown before your files are replaced).
53
+
54
+ ## Next step
55
+
56
+ Start the local host and typegen watcher:
57
+
58
+ ```bash
59
+ npx rayfin dev functions apply
60
+ ```
61
+
62
+ See [`dev functions apply`](./dev-apply.md).
@@ -61,9 +61,43 @@ For the full walkthrough, see the [CLI Quickstart](./quickstart.md) or the [Buil
61
61
  | `npx rayfin up` | Deploy the project to Microsoft Fabric. If you are not signed in, the CLI launches an interactive login flow. Use `-t, --tenant <id>` when your account spans multiple tenants, `-w, --workspace <name>` for a Fabric workspace display name, `-n, --dry-run` to preview without API calls, and `-v, --verbose` for detailed output. Pass `--encryption-fallback-enabled` only when login fails with a keychain error to allow plaintext token storage on systems without OS credential storage, such as some Linux distros, dev containers, and Codespaces. Use `--exclude-services staticHosting` to skip static content build/package/deploy while leaving runtime settings untouched — useful during local development when Vite serves the frontend. Applies runtime settings, database configuration, and static content when enabled. |
62
62
  | `npx rayfin up status` | Display the status of the Fabric deployment (add `--json` for machine-readable output). |
63
63
  | `npx rayfin up db apply` | Generate and apply DAB configuration to the remote Rayfin item. Add `--force` to allow changes that may cause data loss. |
64
- | `npx rayfin up secrets apply` | Read secrets from `rayfin/.env` file (prefixed with `RAYFIN_SECRET_`) and securely apply them to the remote Rayfin item workload. Validates that secrets are persisted. Use `--env-file <path>` to specify a custom .env file location. |
65
64
  | `npx rayfin up staticapp deploy` | Build, package, and deploy static content to the remote Rayfin item. Add `--skip-build` to deploy existing build output without rebuilding. |
66
65
 
66
+ ### Functions
67
+
68
+ Functions are server-side user-defined functions (UDFs) that run in the Fabric runtime and are invocable from your frontend through `RayfinClient`. Use them for logic that must run on the backend — secrets, privileged data access, and server-side validation. See [Functions](./functions/index.md) for the full guide.
69
+
70
+ | Command | Description |
71
+ | --- | --- |
72
+ | `npx rayfin functions init [directory]` | Scaffold `rayfin/functions/`, enable the functions service, install dependencies, build, and generate types. See [functions init](./functions/init.md). |
73
+ | `npx rayfin dev functions apply` | Run the local function host with a live typegen watcher and debugger support. See [dev functions apply](./functions/dev-apply.md). |
74
+ | `npx rayfin up functions deploy` | Build, package, and deploy functions to the remote Rayfin item. `rayfin up` runs this automatically. See [up functions deploy](./functions/deploy.md). |
75
+
76
+ ### Connectors
77
+
78
+ Connectors let a Rayfin app read from — and, for some types, write to — Microsoft Fabric data sources. See [Connectors](./connectors/index.md) for the full guide.
79
+
80
+ | Command | Description |
81
+ | --- | --- |
82
+ | `npx rayfin connector search [query]` | Discover Fabric sources the signed-in identity can add before you know exact workspace or item IDs. See [connector search](./connectors/search.md). |
83
+ | `npx rayfin connector add --type <type> --workspace-id <ws-id> --item-id <item-id>` | Declare a connector in `rayfin.yml` and scaffold `rayfin/connectors/<name>/`. See [connector add](./connectors/add.md). |
84
+ | `npx rayfin connector inspect` | Explore a connector's underlying source in read-only mode by listing entity names, sampling one entity, or running a `.sql` / `.dax` query file. See [connector inspect](./connectors/inspect.md). |
85
+ | `npx rayfin connector invoke <connector-name> <operation>` | Run a single named operation against a configured connector. See [connector invoke](./connectors/invoke.md). |
86
+ | `npx rayfin connector list` | Print the configured connectors. See [Connectors](./connectors/index.md#where-connector-state-lives). |
87
+ | `npx rayfin connector remove <name>` | Delete both the `rayfin.yml` entry and the `rayfin/connectors/<name>/` directory. See [Connectors](./connectors/index.md#where-connector-state-lives). |
88
+ | `npx rayfin up connector apply [--name <name>]` | Re-apply DAB config only. See [Deploying connectors](./connectors/index.md#deploying-connectors). |
89
+
90
+ ### Secrets
91
+
92
+ Secrets are encrypted values stored on your deployed Rayfin item and read at runtime — for example by [functions](./functions/index.md) via `ctx.getSecret`. See [Managing Secrets](./secrets.md) for the full guide.
93
+
94
+ | Command | Description |
95
+ | --- | --- |
96
+ | `npx rayfin secret set <name>` | Set a single secret on the deployed item with a masked prompt. Use `--stdin` for non-interactive input and `--describe="..."` to record a description in `rayfin.yml`. |
97
+ | `npx rayfin secret set --env-file <path>` | Bulk-set every `KEY=VALUE` entry from a dotenv file. |
98
+ | `npx rayfin secret list` | List secret names and their created/updated timestamps (values are never returned). |
99
+ | `npx rayfin secret delete <name>` | Delete a secret from the deployed item. Add `-y, --yes` to skip the confirmation prompt. |
100
+
67
101
  ## Update the CLI
68
102
 
69
103
  To get the latest version of the Rayfin CLI and its dependencies: