@microsoft/rayfin-guide 1.1.0 → 1.33.0-beta.0

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.
@@ -0,0 +1,257 @@
1
+ ---
2
+ sidebar_position: 45
3
+ ---
4
+
5
+ # Deploy to Microsoft Fabric
6
+
7
+ Rayfin deploys your entire application stack to Microsoft Fabric with a single command.
8
+ The CLI handles authentication, resource provisioning, database schema application, and static content hosting so you can go from local development to a live URL in minutes.
9
+
10
+ ## Prerequisites
11
+
12
+ - A Rayfin project with a `rayfin/rayfin.yml` configuration file.
13
+ - A Microsoft account with access to a Fabric workspace.
14
+
15
+ ## Sign in
16
+
17
+ Authenticate with your Microsoft Entra ID account before deploying:
18
+
19
+ ```bash
20
+ npx rayfin login
21
+ ```
22
+
23
+ The CLI opens a browser window for interactive sign-in.
24
+ After authentication, tokens are stored securely in the OS keychain under `~/.rayfin/`.
25
+
26
+ Check your sign-in status at any time:
27
+
28
+ ```bash
29
+ npx rayfin login status
30
+ ```
31
+
32
+ To force an account selection prompt when multiple accounts are available:
33
+
34
+ ```bash
35
+ npx rayfin login --select
36
+ ```
37
+
38
+ ### Non-interactive login
39
+
40
+ Authenticate as a service principal using client credentials when interactive browser login is not available or desired:
41
+
42
+ ```bash
43
+ npx rayfin login --service-principal \
44
+ --client-id <app-registration-client-id> \
45
+ --client-secret <secret> \
46
+ --tenant <tenant-id>
47
+ ```
48
+
49
+ Credentials are persisted to `~/.rayfin/` so all subsequent commands in the same pipeline job authenticate automatically.
50
+ No browser or user interaction is required.
51
+
52
+ Alternatively, set the `RAYFIN_TOKEN` environment variable with a pre-acquired Bearer token to bypass MSAL entirely.
53
+ See [Environment variables](../cli/environment-variables.md#shell-only-variables) for details.
54
+
55
+ ## Deploy with `rayfin up`
56
+
57
+ Run the following command from your project root:
58
+
59
+ ```bash
60
+ npx rayfin up
61
+ ```
62
+
63
+ If you are not signed in, the CLI launches an interactive login flow automatically.
64
+
65
+ ### What `rayfin up` does
66
+
67
+ The command performs these steps in order:
68
+
69
+ 1. **Creates a Rayfin item** in your Fabric workspace (or reuses the existing one on subsequent deploys).
70
+ 1. **Retrieves the publishable key** from the remote service.
71
+ 1. **Syncs runtime settings** from your `rayfin.yml` to the remote service, including auth configuration and service flags.
72
+ 1. **Applies the database schema** generated from your TypeScript data model decorators.
73
+ 1. **Builds and deploys static content** if `staticHosting` is enabled in `rayfin.yml` — runs your build command, packages the output folder into a ZIP, and uploads it.
74
+ 1. **Persists deployment details** to `rayfin/.deployments.json` and merges `RAYFIN_PUBLIC_*` variables into `rayfin/.env` for subsequent deploys.
75
+
76
+ After deployment, the CLI prints:
77
+
78
+ - The **hosting URL** where your app is live.
79
+ - A **Fabric portal link** to manage the deployment.
80
+ - The **deployment ID** for reference.
81
+
82
+ ### Deployment output
83
+
84
+ Each deployment is recorded in `rayfin/.deployments.json` (the registry of every workspace you have deployed to from this project), and the corresponding `RAYFIN_PUBLIC_*` variables are merged into `rayfin/.env` so subsequent commands and your frontend pick up the same values.
85
+
86
+ For frontend frameworks, the CLI also runs `rayfin env` to emit a framework-specific `.env.local` (e.g. for Vite) before the static build. That file is what your client code reads at runtime.
87
+
88
+ ```text title="rayfin/.deployments.json"
89
+ {
90
+ "active": "myworkspace",
91
+ "deployments": {
92
+ "myworkspace": {
93
+ "fabricItemId": "7db00cb9-f630-4ecf-8fc9-942e60af5d78",
94
+ "fabricApiUrl": "https://...",
95
+ "fabricWorkspaceId": "8b17cf64-3c12-46ac-a572-192732c32641",
96
+ "fabricTenantId": "...",
97
+ "publishableKey": "pk-nua-EHihY2jz71V65YB4",
98
+ "fabricPortalUrl": "https://dxt.fabric.microsoft.com/",
99
+ "hostingUrl": "https://silky-sand-4924b3ad1f-centraluseuap.webapp.rayfingwdev.com",
100
+ "deployedAt": "2026-04-28T01:15:50.514Z"
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ The matching `.env.local` (auto-generated by `rayfin env --framework vite`) looks like:
107
+
108
+ ```bash title=".env.local"
109
+ VITE_FABRIC_ITEM_ID=7db00cb9-f630-4ecf-8fc9-942e60af5d78
110
+ VITE_RAYFIN_API_URL=https://...
111
+ VITE_FABRIC_WORKSPACE_ID=8b17cf64-3c12-46ac-a572-192732c32641
112
+ VITE_RAYFIN_PUBLISHABLE_KEY=pk-nua-EHihY2jz71V65YB4
113
+ VITE_FABRIC_PORTAL_URL=https://dxt.fabric.microsoft.com/
114
+ ```
115
+
116
+ | Variable | Description |
117
+ | --- | --- |
118
+ | `VITE_FABRIC_ITEM_ID` | The Fabric item ID for this deployment. |
119
+ | `VITE_RAYFIN_API_URL` | Full URL to the deployed Rayfin backend API. |
120
+ | `VITE_FABRIC_WORKSPACE_ID` | The Fabric workspace ID containing the deployment. |
121
+ | `VITE_RAYFIN_PUBLISHABLE_KEY` | Publishable key used by the Rayfin client for authentication. |
122
+ | `VITE_FABRIC_PORTAL_URL` | URL to the Fabric portal for managing the deployment. |
123
+ | `VITE_RAYFIN_HOSTING_URL` | Public URL where your static content is hosted. |
124
+
125
+ ### Authentication after deployment
126
+
127
+ Only **Fabric brokered authentication (Entra SSO)** is supported on deployed applications. Email and password authentication is available during local development but does not work after deploying to Fabric.
128
+
129
+ Ensure your `rayfin.yml` has Fabric auth enabled before running `rayfin up`:
130
+
131
+ ```yaml
132
+ services:
133
+ auth:
134
+ enabled: true
135
+ fabric:
136
+ enabled: true
137
+ ```
138
+
139
+ ### Preview without deploying
140
+
141
+ Use `-n, --dry-run` to see what the CLI would do without creating or modifying any resources:
142
+
143
+ ```bash
144
+ npx rayfin up -n
145
+ ```
146
+
147
+ ### Skip specific services
148
+
149
+ Use `--exclude-services <names>` to skip the build/package/deploy phase for supported services without touching the rest of the deployment.
150
+ The runtime settings POST still reflects your `rayfin.yml`, so the backend is never silently reconfigured.
151
+ The only currently supported value is `staticHosting`; other names fail with a clear error.
152
+
153
+ The canonical use case is local development where Vite serves the frontend locally, so you want the backend deployed but not the static bundle:
154
+
155
+ ```bash
156
+ npx rayfin up --exclude-services staticHosting
157
+ ```
158
+
159
+ The samples and templates use this flag in their `npm run dev` script.
160
+
161
+ ## Apply database changes remotely
162
+
163
+ After updating your data models, push schema changes to the remote database without redeploying the full stack:
164
+
165
+ ```bash
166
+ npx rayfin up db apply
167
+ ```
168
+
169
+ If the schema change involves potentially destructive operations (dropping columns, renaming tables), the CLI warns you and refuses to proceed.
170
+ Use `--force` to override the safety check:
171
+
172
+ ```bash
173
+ npx rayfin up db apply --force
174
+ ```
175
+
176
+ ## Redeploy static content
177
+
178
+ When you have only changed frontend code, redeploy static content independently for a faster iteration cycle:
179
+
180
+ ```bash
181
+ npx rayfin up staticapp deploy
182
+ ```
183
+
184
+ This runs your configured `buildCommand`, packages the output, and uploads it to the remote service.
185
+
186
+ To skip the build step and deploy existing output:
187
+
188
+ ```bash
189
+ npx rayfin up staticapp deploy --skip-build
190
+ ```
191
+
192
+ ## Check deployment status
193
+
194
+ View the current state of your Fabric deployment:
195
+
196
+ ```bash
197
+ npx rayfin up status
198
+ ```
199
+
200
+ Add `--json` for machine-readable output:
201
+
202
+ ```bash
203
+ npx rayfin up status --json
204
+ ```
205
+
206
+ ## Sign out
207
+
208
+ Clear cached credentials when you are done or need to switch accounts:
209
+
210
+ ```bash
211
+ npx rayfin logout
212
+ ```
213
+
214
+ ## Subsequent deployments
215
+
216
+ After the first deploy, `rayfin/.deployments.json` records the deployment metadata and the matching `RAYFIN_PUBLIC_*` values are merged into `rayfin/.env`. The frontend `.env.local` (generated by `rayfin env --framework vite`) reflects those values (`VITE_FABRIC_ITEM_ID`, `VITE_FABRIC_WORKSPACE_ID`, and the API endpoint).
217
+ Running `npx rayfin up` again updates the same deployment rather than creating a new one.
218
+
219
+ For targeted updates, use the subcommands:
220
+
221
+ | Command | What it updates |
222
+ | --- | --- |
223
+ | `npx rayfin up` | Everything: settings, database, and static content. |
224
+ | `npx rayfin up db apply` | Database schema only. |
225
+ | `npx rayfin up staticapp deploy` | Static content only. |
226
+
227
+ ## Troubleshooting
228
+
229
+ ### Deployment fails with 401 or 403
230
+
231
+ Your session may have expired. Run `npx rayfin login` to reauthenticate, then retry `npx rayfin up`.
232
+
233
+ ### Database apply reports destructive changes
234
+
235
+ The CLI blocks schema changes that could cause data loss. Review the listed operations and use `npx rayfin up db apply --force` only after confirming you accept the data loss.
236
+
237
+ ### Deployment fails with "Dialect is required"
238
+
239
+ Enabling `data: enabled: true` in `rayfin.yml` without specifying a `dialect` causes a 400 error during `rayfin up`.
240
+ Add `dialect: mssql` (or `postgresql` for local dev) under the `data` section:
241
+
242
+ ```yaml
243
+ services:
244
+ data:
245
+ enabled: true
246
+ dialect: mssql
247
+ ```
248
+
249
+ ### Static deploy exceeds size limit
250
+
251
+ The compressed archive must not exceed 100 MB. Optimize your build output by excluding source maps and large development assets, or move binary files to Rayfin storage.
252
+
253
+ ### GraphQL returns "Internal server error" after deploy
254
+
255
+ If `rayfin up` succeeded but the app fails with GraphQL errors at runtime, check for `@text()` fields without `max` in your entity definitions.
256
+ These generate `NVARCHAR(MAX)` columns on MSSQL, which can prevent DAB from building its GraphQL schema.
257
+ Add explicit `max` constraints (e.g., `@text({ max: 200 })`), then redeploy with `npx rayfin up db apply --force`.
@@ -0,0 +1,126 @@
1
+ ---
2
+ sidebar_position: 2
3
+ title: Fabric Data App in Microsoft Fabric
4
+ ---
5
+
6
+ A **Fabric data app** is a Fabric item that hosts your Rayfin application as a managed service.
7
+ When you create a Fabric data app in a Fabric workspace, Fabric provisions and manages the backend infrastructure — database, authentication, static hosting, and API endpoints — so you can focus on your application code.
8
+
9
+ ## What is a Fabric data app?
10
+
11
+ A Fabric data app is the Fabric representation of your Rayfin project.
12
+ It contains all the services your application needs, exposed through a single Rayfin endpoint.
13
+
14
+ ```mermaid
15
+ flowchart TD
16
+ AppBackend[Fabric Data App] --> Database[(SQL Database)]
17
+ AppBackend --> Auth[Authentication]
18
+ AppBackend --> StaticHosting[Static Content]
19
+ AppBackend --> WebService[Rayfin WebService]
20
+ WebService --> DataApi[Data API / GraphQL]
21
+ DataApi --> Database
22
+ ```
23
+
24
+ Each Fabric data app lives inside a Fabric workspace.
25
+ You can create multiple Fabric data apps in the same workspace for different applications or environments.
26
+
27
+ ## Prerequisites
28
+
29
+ ### Fabric capacity
30
+
31
+ Your workspace must have Fabric capacity assigned. When creating a new workspace, select a Fabric capacity to associate with it. Rayfin services consume capacity units from the assigned capacity.
32
+
33
+ ### Tenant admin settings
34
+
35
+ A Fabric tenant administrator must enable the Fabric data app workload before users can create items.
36
+
37
+ 1. Sign in to the [Fabric admin portal](https://app.fabric.microsoft.com/admin-portal).
38
+ 2. Navigate to **Tenant settings**.
39
+ 3. Under **Fabric Apps (preview)**, toggle the setting to **Enabled**.
40
+ 4. Choose whether to enable for the entire organization or specific security groups.
41
+ 5. Click **Apply**.
42
+
43
+ Changes may take a few minutes to propagate.
44
+
45
+ ## Child services
46
+
47
+ When you deploy your application with `rayfin up`, Fabric provisions child services based on your `rayfin.yml` configuration.
48
+ These child services appear as child items under the Fabric data app in the Fabric portal.
49
+
50
+ | Child service | What it provides | Portal capabilities |
51
+ | --- | --- | --- |
52
+ | **SQL Database** | MSSQL database with your schema applied from TypeScript data model decorators. | View database, run queries with the query editor, copy connection string. The database is read-only in the portal — schema changes must come from your code via `rayfin up`. |
53
+ | **Authentication** | Fabric brokered auth using Microsoft Entra ID (SSO). Users sign in through their existing Fabric identity. | View authenticated users inthe SQL Database. |
54
+ | **Static Content** | Your built frontend assets (HTML, CSS, JS) served at a public URL. This uses OneLake storage. | View hosting URL. Assets are updated on each deploy. |
55
+
56
+ ## Rayfin endpoint
57
+
58
+ Each Fabric data app has a single Rayfin endpoint that provides access to all services:
59
+
60
+ ```text
61
+ https://<your-app>-app.rayfin.windows.net/
62
+ ```
63
+
64
+ The endpoint exposes paths for each service:
65
+
66
+ | Path | Service |
67
+ | --- | --- |
68
+ | `/api/graphql` | Data API (GraphQL) — used by `RayfinClient` for CRUD operations |
69
+ | `/auth` | Authentication service |
70
+ | `/storage` | File storage |
71
+
72
+ Your frontend application uses this endpoint via the `VITE_RAYFIN_API_URL` environment variable, which is generated into `.env.local` from `rayfin/.env` after deployment.
73
+
74
+ ## Deployment
75
+
76
+ You deploy your application to a Fabric data app using the `rayfin up` CLI command or the **Project Rayfin: Up: Deploy to Fabric** command in VS Code.
77
+
78
+ ### What happens during deployment
79
+
80
+ 1. **Item creation** — The CLI creates a Fabric data app in your Fabric workspace (first deploy) or connects to the existing one (subsequent deploys).
81
+ 2. **Publishable key** — A publishable key is retrieved from the remote service and stored in `rayfin.yml`. **This cannot be modified.**
82
+ 3. **Settings sync** — Runtime settings from `rayfin.yml` are pushed to the remote service, including auth configuration and enabled services.
83
+ 4. **Schema application** — The database schema generated from your TypeScript decorators is applied to the remote MSSQL instance.
84
+ 5. **Static content** — If `staticHosting` is enabled, the CLI runs your build command, packages the output, and uploads it.
85
+ 6. **Output** — Deployment details are recorded in `rayfin/.deployments.json` and the matching `RAYFIN_PUBLIC_*` values are merged into `rayfin/.env` for use by your frontend and subsequent deploys.
86
+
87
+ ## Management in the Fabric portal
88
+
89
+ After deployment, you can manage your Fabric data app directly in the Fabric portal.
90
+
91
+ ### Viewing item properties
92
+
93
+ Open the Fabric data app in the portal to see:
94
+
95
+ - **Rayfin endpoint** — The base URL for all services. Copy it for use in environment configuration.
96
+ - **App URL** — The public URL where your static content is hosted.
97
+ - **Fabric portal link** — Direct link to manage the deployment.
98
+
99
+ ### Managing child items
100
+
101
+ Click into the Fabric data app to see its child services:
102
+
103
+ - **SQL Database** — Opens the Fabric SQL query editor. You can run read queries against your data. Schema changes made directly in the portal are overwritten on the next `rayfin up` deploy.
104
+ - **Authentication** — View and manage authenticated users in **Users** table in the SQL Database.
105
+
106
+ ### Permissions
107
+
108
+ Workspace roles do not supersede item-level permissions.
109
+ To share an app with someone in your organization, they need **Run and interact** permission, that is, **Read and execute**, to run the app and invoke the backend APIs.
110
+
111
+ The table below shows what each permission level allows:
112
+
113
+ | Permission | What it allows |
114
+ | --- | --- |
115
+ | **Run and interact** (default) | Open and use the deployed application. All workspace members receive this level by default. |
116
+ | **Edit (Write)** | Modify the Fabric data app — deploy code with `rayfin up`, apply schema changes, update settings, and manage child services. Requires **contributor** or **admin** role on the workspace. |
117
+ | **Reshare** | Grant other users access to the Fabric data app. Requires **admin** role on the workspace. |
118
+
119
+ Learn more about [Workspace roles](https://learn.microsoft.com/fabric/fundamentals/roles-workspaces)
120
+
121
+ ## Next steps
122
+
123
+ - [Pricing and capacity usage](./pricing.md) — Understand what consumes Fabric capacity and how billing works.
124
+ - [Create a Fabric data app](../getting-started/create-rayfin-item.md) — Step-by-step guide to creating your first item in the Fabric portal.
125
+ - [Deploy to Microsoft Fabric](./deploy.md) — Detailed deployment commands and troubleshooting.
126
+ - [Fabric Brokered Auth](../auth/fabric.md) — How Fabric SSO authentication works.
@@ -0,0 +1,66 @@
1
+ ---
2
+ sidebar_position: 2
3
+ title: Pricing and capacity usage
4
+ ---
5
+
6
+ Fabric data apps run on Microsoft Fabric capacity.
7
+ There are **no additional Rayfin-specific charges** — you pay only for the Fabric capacity units (CUs) consumed by the underlying services your application uses.
8
+
9
+ ## How billing works
10
+
11
+ Fabric uses a universal billing model based on **Capacity Units (CUs)**.
12
+ Every operation performed by a Fabric data app child service consumes CUs from the Fabric capacity assigned to your workspace.
13
+
14
+ Your workspace must have a Fabric capacity associated with it.
15
+ CU consumption is tracked in the [Microsoft Fabric Capacity Metrics app](https://learn.microsoft.com/fabric/enterprise/metrics-app) where you can monitor usage per item and per operation.
16
+
17
+ ## What consumes capacity
18
+
19
+ A Fabric data app uses three Fabric services that consume CUs:
20
+
21
+ ### SQL Database
22
+
23
+ The SQL Database child item consumes CUs for compute and storage.
24
+
25
+ | Operation | What it covers | Billing meter | Type |
26
+ | --- | --- | --- | --- |
27
+ | **SQL Usage** | Compute for all SQL queries, modifications, and data processing — includes queries from your application's GraphQL API and any queries you run in the Fabric portal query editor. | SQL database in Microsoft Fabric Capacity Usage CU | Interactive |
28
+ | **Allocated SQL Storage** | Dynamically allocated storage for tables, indexes, transaction logs, and metadata. Fully integrated with OneLake. | SQL Storage Data Stored | Background |
29
+
30
+ One Fabric CU equals 0.383 SQL database vCores.
31
+
32
+ ### GraphQL API
33
+
34
+ Every GraphQL query (read) and mutation (write) made by your application's `RayfinClient` consumes CUs.
35
+ The consumption rate is ten CUs per hour of request and response processing time.
36
+
37
+ | Operation | What it covers | Billing meter | Type |
38
+ | --- | --- | --- | --- |
39
+ | **Query** | Compute for all GraphQL queries (reads) and mutations (writes) performed by API clients against your data models. | API for GraphQL Query Capacity Usage CU | Interactive |
40
+
41
+ For more details, see [Fabric API for GraphQL](https://learn.microsoft.com/en-us/fabric/enterprise/fabric-operations#fabric-api-for-graphql) in the Fabric operations documentation.
42
+
43
+ ### OneLake storage (static content)
44
+
45
+ When static hosting is enabled, your built frontend assets (HTML, CSS, JS) are stored in OneLake and served from a public URL.
46
+ OneLake storage and the read/write operations to serve content consume CUs.
47
+
48
+ | Operation | What it covers | Billing meter | Type |
49
+ | --- | --- | --- | --- |
50
+ | **OneLake Read** | Read operations when serving static content to end users. | OneLake Read Operations Capacity Usage CU | Background |
51
+ | **OneLake Write** | Write operations when deploying or updating static content via `rayfin up`. | OneLake Write Operations Capacity Usage CU | Background |
52
+ | **OneLake Storage** | Storage of static content files in OneLake. | OneLake Storage | Background |
53
+
54
+ ## What does not consume additional capacity
55
+
56
+ The following Fabric data app capabilities do **not** incur separate CU charges at this time:
57
+
58
+ - **Rayfin WebService** — The application backend service that handles API routing and authentication.
59
+ - **Authentication** — Fabric brokered auth (Entra SSO) sign-in and session management.
60
+ - **Deployment operations** — Running `rayfin up` to deploy your application does not have its own CU charge beyond the SQL and OneLake operations it triggers.
61
+
62
+ ## Further reading
63
+
64
+ - [Fabric operations](https://learn.microsoft.com/en-us/fabric/enterprise/fabric-operations) — Full list of Fabric operations and their capacity consumption rates.
65
+ - [Microsoft Fabric Capacity Metrics app](https://learn.microsoft.com/en-us/fabric/enterprise/metrics-app) — Monitor and understand your capacity usage.
66
+ - [Fabric Data App in Fabric](./index.md) — Overview of the Fabric data app and its child services.