@microsoft/rayfin-guide 1.1.0 → 1.33.0-beta.1
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.
- package/assets/docs/app-backend/deploy.md +256 -0
- package/assets/docs/app-backend/index.md +126 -0
- package/assets/docs/app-backend/pricing.md +66 -0
- package/assets/docs/auth/fabric.md +328 -0
- package/assets/docs/auth/index.md +33 -0
- package/assets/docs/auth/overview.md +130 -0
- package/assets/docs/cli/ai-files.md +146 -0
- package/assets/docs/cli/env-interpolation.md +187 -0
- package/assets/docs/cli/env-migration.md +135 -0
- package/assets/docs/cli/environment-variables.md +173 -0
- package/assets/docs/cli/index.md +84 -0
- package/assets/docs/cli/installation.md +107 -0
- package/assets/docs/cli/quickstart.md +88 -0
- package/assets/docs/data/graphql.md +267 -0
- package/assets/docs/data/index.md +20 -0
- package/assets/docs/data/overview.md +270 -0
- package/assets/docs/data/permissions.md +172 -0
- package/assets/docs/data/validation.md +165 -0
- package/assets/docs/getting-started/create-app-with-cli.md +118 -0
- package/assets/docs/getting-started/create-rayfin-item.md +73 -0
- package/assets/docs/getting-started/index.md +201 -0
- package/assets/docs/getting-started/project-structure.md +290 -0
- package/assets/docs/hosting/index.md +183 -0
- package/assets/docs/index.md +92 -45
- package/assets/docs/known-limitations.md +50 -0
- package/assets/docs/preview/local-dev-docker.md +124 -0
- package/package.json +1 -1
- package/assets/docs/quickstart.md +0 -81
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Environment Variable Interpolation
|
|
6
|
+
|
|
7
|
+
Rayfin supports environment variable interpolation in `rayfin.yml` configuration files using Docker Compose-style syntax.
|
|
8
|
+
This allows you to manage environment-specific values (connection strings, API keys, URLs) without hard-coding sensitive data in your configuration.
|
|
9
|
+
|
|
10
|
+
## Syntax
|
|
11
|
+
|
|
12
|
+
Rayfin supports two interpolation patterns:
|
|
13
|
+
|
|
14
|
+
- `${VAR}` - Simple variable substitution (fails if variable is unset or empty).
|
|
15
|
+
- `${VAR:-default}` - Substitution with default value if variable is unset or empty.
|
|
16
|
+
|
|
17
|
+
Following Docker Compose semantics, the `:-` operator treats both undefined and empty string values as requiring the default.
|
|
18
|
+
|
|
19
|
+
**Examples:**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# .env file
|
|
23
|
+
DEFINED=value
|
|
24
|
+
EMPTY=
|
|
25
|
+
# UNDEFINED is not set
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```yaml
|
|
29
|
+
# rayfin.yml - Results:
|
|
30
|
+
config1: ${DEFINED} # → "value" (uses variable)
|
|
31
|
+
config2: ${EMPTY:-fallback} # → "fallback" (empty, uses default)
|
|
32
|
+
config3: ${UNDEFINED:-fallback} # → "fallback" (unset, uses default)
|
|
33
|
+
config4: ${DEFINED:-fallback} # → "value" (defined, ignores default)
|
|
34
|
+
config5: ${EMPTY} # → Error! (empty without default)
|
|
35
|
+
config6: ${UNDEFINED} # → Error! (unset without default)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Basic Substitution
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
# rayfin.yml
|
|
44
|
+
services:
|
|
45
|
+
data:
|
|
46
|
+
host: ${DB_HOST}
|
|
47
|
+
port: ${DB_PORT}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# .env file (rayfin/.env)
|
|
52
|
+
DB_HOST=localhost
|
|
53
|
+
DB_PORT=5432
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Default Values
|
|
57
|
+
|
|
58
|
+
Provide fallback values when environment variables are not set:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
services:
|
|
62
|
+
data:
|
|
63
|
+
host: ${DB_HOST:-localhost}
|
|
64
|
+
port: ${DB_PORT:-5432}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Partial Interpolation
|
|
68
|
+
|
|
69
|
+
Combine static text with variables:
|
|
70
|
+
|
|
71
|
+
```yaml
|
|
72
|
+
services:
|
|
73
|
+
auth:
|
|
74
|
+
issuer: https://${AUTH_DOMAIN}/oauth
|
|
75
|
+
connectionString: Server=${DB_HOST};Port=${DB_PORT};Database=${DB_NAME}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## .env File Location
|
|
79
|
+
|
|
80
|
+
By default, Rayfin loads environment variables from `rayfin/.env`.
|
|
81
|
+
You can customize this in three ways:
|
|
82
|
+
|
|
83
|
+
1. **CLI argument** (highest priority):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
rayfin up --env-file /custom.env
|
|
87
|
+
rayfin up --env-file /production.env
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. **Environment variable**:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
export RAYFIN_ENV_FILE='/staging.env'
|
|
94
|
+
rayfin up
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
3. **Default**: `rayfin/.env`
|
|
98
|
+
|
|
99
|
+
## Environment Priority
|
|
100
|
+
|
|
101
|
+
When resolving variable values, Rayfin follows this priority:
|
|
102
|
+
|
|
103
|
+
1. Shell environment variables (if non-empty).
|
|
104
|
+
2. Variables from `.env` file (if non-empty).
|
|
105
|
+
3. Default values (if specified with `:-` syntax and variable is unset or empty).
|
|
106
|
+
4. Error if variable is unset or empty and no default is provided.
|
|
107
|
+
|
|
108
|
+
## Type Coercion
|
|
109
|
+
|
|
110
|
+
Rayfin automatically converts interpolated values to appropriate YAML types:
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
# rayfin.yml
|
|
114
|
+
services:
|
|
115
|
+
data:
|
|
116
|
+
port: ${DB_PORT} # Becomes number 5432, not string "5432"
|
|
117
|
+
enabled: ${ENABLED} # Becomes boolean true, not string "true"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# .env
|
|
122
|
+
DB_PORT=5432
|
|
123
|
+
ENABLED=true
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Type coercion only applies when the entire value is a variable reference.
|
|
127
|
+
Partial interpolation always produces strings:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
url: http://localhost:${PORT} # Results in string "http://localhost:5432"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Example: Todo App Configuration
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
# rayfin.yml
|
|
137
|
+
id: ${PROJECT_NAME:-todo-app}
|
|
138
|
+
|
|
139
|
+
services:
|
|
140
|
+
data:
|
|
141
|
+
enabled: ${DATA_ENABLED:-true}
|
|
142
|
+
connectionString: Server=${DB_HOST:-localhost};Port=${DB_PORT:-5432};Database=${DB_NAME:-tododb}
|
|
143
|
+
|
|
144
|
+
auth:
|
|
145
|
+
enabled: ${AUTH_ENABLED:-false}
|
|
146
|
+
issuer: ${AUTH_ISSUER}
|
|
147
|
+
audience: ${AUTH_AUDIENCE:-https://api.example.com}
|
|
148
|
+
|
|
149
|
+
storage:
|
|
150
|
+
enabled: ${STORAGE_ENABLED:-true}
|
|
151
|
+
accountName: ${STORAGE_ACCOUNT:-devstoreaccount1}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# rayfin/.env
|
|
156
|
+
PROJECT_NAME=my-todo-app
|
|
157
|
+
DB_HOST=production-db.example.com
|
|
158
|
+
DB_PORT=5432
|
|
159
|
+
DB_NAME=todos_prod
|
|
160
|
+
AUTH_ENABLED=true
|
|
161
|
+
AUTH_ISSUER=https://auth.example.com
|
|
162
|
+
STORAGE_ACCOUNT=prodstorageaccount
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Security Best Practices
|
|
166
|
+
|
|
167
|
+
1. **Never commit `.env` files** - They contain secrets and environment-specific values.
|
|
168
|
+
2. **Provide `.env.example`** - Document required variables for other developers.
|
|
169
|
+
3. **Use shell environment in CI/CD** - Override `.env` with build and deployment secrets.
|
|
170
|
+
4. **Validate required variables** - Omit default values for required configuration.
|
|
171
|
+
|
|
172
|
+
## Error Handling
|
|
173
|
+
|
|
174
|
+
Rayfin fails fast with clear error messages when variables are missing:
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
❌ Environment variable 'DB_HOST' referenced in rayfin.yml (services.data.host) is not defined.
|
|
178
|
+
Set it in .env file or shell environment.
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
This prevents configuration errors from reaching runtime.
|
|
182
|
+
|
|
183
|
+
## Environment Variable Reference
|
|
184
|
+
|
|
185
|
+
### Special Variables
|
|
186
|
+
|
|
187
|
+
- `RAYFIN_ENV_FILE` - Override default `.env` file path.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Environment file migration (CLI 1.17)
|
|
2
|
+
|
|
3
|
+
Starting with Rayfin CLI 1.17.0, environment files are simplified from 10+ files across two directories down to **two runtime files**: `rayfin/.env` (gitignored) and `rayfin/.deployments.json` (gitignored).
|
|
4
|
+
This guide covers what changed and what — if anything — you need to do.
|
|
5
|
+
|
|
6
|
+
## Vite projects (most common)
|
|
7
|
+
|
|
8
|
+
If your project uses Vite (the default for all Rayfin templates), **migration is automatic**.
|
|
9
|
+
Run this command as you normally would:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx rayfin up
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The CLI does the rest:
|
|
16
|
+
|
|
17
|
+
1. Detects `vite.config.ts` (or `vite` in `package.json`) and auto-generates `.env.local` with Vite-compatible variable names.
|
|
18
|
+
2. Writes deployment or runtime values to `rayfin/.env` using the new `RAYFIN_PUBLIC_*` naming convention.
|
|
19
|
+
|
|
20
|
+
**Your frontend code does not change.**
|
|
21
|
+
`import.meta.env.VITE_RAYFIN_API_URL`, `import.meta.env.VITE_FABRIC_ITEM_ID`, and all other `VITE_*` variables resolve exactly as before.
|
|
22
|
+
|
|
23
|
+
### After the first run
|
|
24
|
+
|
|
25
|
+
You will see a warning listing leftover v1 files:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
⚠️ Detected env-strategy v1 artifacts. The Rayfin CLI no longer reads
|
|
29
|
+
these files; follow the steps below so your project keeps working.
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Follow the printed instructions, then delete the stale files:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
rm -f .env.fabric .env.fabric-*
|
|
36
|
+
rm -f rayfin/.temp/.env
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
These files are harmless if left behind — the CLI ignores them — but removing them avoids confusion.
|
|
40
|
+
|
|
41
|
+
### What the new layout looks like
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
project-root/
|
|
45
|
+
├── rayfin/
|
|
46
|
+
│ ├── rayfin.yml # committed (unchanged)
|
|
47
|
+
│ ├── .env # gitignored — all runtime/deployment values
|
|
48
|
+
│ ├── .env.example # committed — documents expected variables
|
|
49
|
+
│ └── .deployments.json # gitignored — multi-deployment registry
|
|
50
|
+
├── .env.local # gitignored — auto-generated by rayfin env
|
|
51
|
+
└── vite.config.ts
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Next.js projects
|
|
55
|
+
|
|
56
|
+
The same auto-detection applies.
|
|
57
|
+
The CLI detects `next.config.*` (or `next` in `package.json`) and maps variables to `NEXT_PUBLIC_*` prefixes instead of `VITE_*`.
|
|
58
|
+
|
|
59
|
+
## Projects without a detectable framework
|
|
60
|
+
|
|
61
|
+
If the CLI cannot auto-detect your framework (no `vite.config.*`, `next.config.*`, or matching `package.json` dependency), pass the `--framework` flag explicitly:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx rayfin env --framework vite
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The CLI prints a hint when no framework is detected, so you will know if this step is needed.
|
|
68
|
+
|
|
69
|
+
## Variable naming changes
|
|
70
|
+
|
|
71
|
+
The underlying variable names changed from framework-specific (`VITE_*`) to framework-agnostic (`RAYFIN_PUBLIC_*`).
|
|
72
|
+
The mapping is handled automatically by `rayfin env`:
|
|
73
|
+
|
|
74
|
+
| `rayfin/.env` (new) | `.env.local` Vite output | `.env.local` Next.js output |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `RAYFIN_PUBLIC_API_URL` | `VITE_RAYFIN_API_URL` | `NEXT_PUBLIC_RAYFIN_API_URL` |
|
|
77
|
+
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | `VITE_RAYFIN_PUBLISHABLE_KEY` | `NEXT_PUBLIC_RAYFIN_PUBLISHABLE_KEY` |
|
|
78
|
+
| `RAYFIN_PUBLIC_ITEM_ID` | `VITE_FABRIC_ITEM_ID` | `NEXT_PUBLIC_FABRIC_ITEM_ID` |
|
|
79
|
+
| `RAYFIN_PUBLIC_WORKSPACE_ID` | `VITE_FABRIC_WORKSPACE_ID` | `NEXT_PUBLIC_FABRIC_WORKSPACE_ID` |
|
|
80
|
+
| `RAYFIN_PUBLIC_PORTAL_URL` | `VITE_FABRIC_PORTAL_URL` | `NEXT_PUBLIC_FABRIC_PORTAL_URL` |
|
|
81
|
+
|
|
82
|
+
You do not need to update your frontend code to use these names.
|
|
83
|
+
The `.env.local` file emitted by `rayfin env` uses the framework-specific names your bundler expects.
|
|
84
|
+
|
|
85
|
+
## Removed: `VITE_RAYFIN_HOSTING_URL`
|
|
86
|
+
|
|
87
|
+
The `VITE_RAYFIN_HOSTING_URL` variable is no longer written to `.env.local`.
|
|
88
|
+
The hosting URL is stored in `rayfin/.deployments.json` for reference only.
|
|
89
|
+
If your frontend code reads this variable, replace it with a direct reference or remove the usage.
|
|
90
|
+
|
|
91
|
+
## Multi-deployment management
|
|
92
|
+
|
|
93
|
+
The per-workspace `.env.fabric-<workspace>` files are replaced by a single `rayfin/.deployments.json` registry.
|
|
94
|
+
Two new commands manage deployments:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx rayfin up list # show all recorded deployments
|
|
98
|
+
npx rayfin up switch staging # switch active deployment, regenerate rayfin/.env
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Switching a deployment regenerates both `rayfin/.env` and `.env.local` automatically.
|
|
102
|
+
|
|
103
|
+
## Manual `rayfin env` usage
|
|
104
|
+
|
|
105
|
+
If you need to regenerate `.env.local` without running `rayfin up`:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx rayfin env --framework vite # emit .env.local for Vite
|
|
109
|
+
npx rayfin env --framework nextjs # emit .env.local for Next.js
|
|
110
|
+
npx rayfin env --show # print resolved variables without writing
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When the `--framework` flag is omitted, `rayfin env` auto-detects from the project files:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npx rayfin env # auto-detects framework
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Edge cases
|
|
120
|
+
|
|
121
|
+
### Custom variables in old `.env.fabric-*` files
|
|
122
|
+
|
|
123
|
+
If you added custom variables (beyond the standard Rayfin set) to your old `.env.fabric-*` files, those are not migrated automatically.
|
|
124
|
+
Add them to `rayfin/.env` after the first `rayfin up` run.
|
|
125
|
+
|
|
126
|
+
### Existing Postgres password in `rayfin/.temp/.env`
|
|
127
|
+
|
|
128
|
+
If you have a local database volume that depends on the generated `RAYFIN_POSTGRES_PASSWORD`, copy that value from `rayfin/.temp/.env` into `rayfin/.env` before running `rayfin up`.
|
|
129
|
+
Otherwise the CLI generates a new password and the database connection fails until the volume is recreated.
|
|
130
|
+
|
|
131
|
+
### `rayfin/.env` backup
|
|
132
|
+
|
|
133
|
+
On the first CLI run after upgrading, the CLI backs up your existing `rayfin/.env` to `rayfin/.env.bak` before rewriting it in the new format.
|
|
134
|
+
Variable values are preserved; comments and ordering are not.
|
|
135
|
+
Diff the two files to recover any custom content.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Environment variables
|
|
2
|
+
|
|
3
|
+
This page is the single reference for every environment variable that Rayfin tooling reads or writes.
|
|
4
|
+
Variables are grouped by purpose and lifecycle.
|
|
5
|
+
|
|
6
|
+
## Frontend-visible variables (`RAYFIN_PUBLIC_*`)
|
|
7
|
+
|
|
8
|
+
These variables live in `rayfin/.env` and are the **only** variables exposed to frontend builds.
|
|
9
|
+
The `rayfin env` command (or the auto-emit built into `rayfin up`) maps them to framework-specific names in `.env.local`.
|
|
10
|
+
|
|
11
|
+
| Variable | Description | Populated by |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `RAYFIN_PUBLIC_API_URL` | Rayfin backend URL (`http://localhost:5168` for local dev). | `rayfin up` |
|
|
14
|
+
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | Public key for Rayfin SDK initialization. | `rayfin up` |
|
|
15
|
+
| `RAYFIN_PUBLIC_ITEM_ID` | Fabric AppBackend item ID. Used for Fabric brokered auth. | `rayfin up` |
|
|
16
|
+
| `RAYFIN_PUBLIC_WORKSPACE_ID` | Fabric workspace ID. Used for Fabric brokered auth. | `rayfin up` |
|
|
17
|
+
| `RAYFIN_PUBLIC_TENANT_ID` | Entra ID tenant for workspace disambiguation. | `rayfin up` |
|
|
18
|
+
| `RAYFIN_PUBLIC_PORTAL_URL` | Fabric Portal base URL (for example, `https://app.fabric.microsoft.com/`). | `rayfin up` |
|
|
19
|
+
| `RAYFIN_PUBLIC_SERVICE_MODE` | `rayfin` (real backend) or `mock` (local testing). | User-set in `rayfin/.env` |
|
|
20
|
+
|
|
21
|
+
### Framework mapping
|
|
22
|
+
|
|
23
|
+
`rayfin env --framework <fw>` maps each `RAYFIN_PUBLIC_*` variable to a framework-specific name:
|
|
24
|
+
|
|
25
|
+
| Source (`rayfin/.env`) | Vite (`.env.local`) | Next.js (`.env.local`) | Plain (`.env.local`) |
|
|
26
|
+
| --- | --- | --- | --- |
|
|
27
|
+
| `RAYFIN_PUBLIC_API_URL` | `VITE_RAYFIN_API_URL` | `NEXT_PUBLIC_RAYFIN_API_URL` | `API_URL` |
|
|
28
|
+
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | `VITE_RAYFIN_PUBLISHABLE_KEY` | `NEXT_PUBLIC_RAYFIN_PUBLISHABLE_KEY` | `PUBLISHABLE_KEY` |
|
|
29
|
+
| `RAYFIN_PUBLIC_ITEM_ID` | `VITE_FABRIC_ITEM_ID` | `NEXT_PUBLIC_FABRIC_ITEM_ID` | `ITEM_ID` |
|
|
30
|
+
| `RAYFIN_PUBLIC_WORKSPACE_ID` | `VITE_FABRIC_WORKSPACE_ID` | `NEXT_PUBLIC_FABRIC_WORKSPACE_ID` | `WORKSPACE_ID` |
|
|
31
|
+
| `RAYFIN_PUBLIC_TENANT_ID` | `VITE_FABRIC_TENANT_ID` | `NEXT_PUBLIC_FABRIC_TENANT_ID` | `TENANT_ID` |
|
|
32
|
+
| `RAYFIN_PUBLIC_PORTAL_URL` | `VITE_FABRIC_PORTAL_URL` | `NEXT_PUBLIC_FABRIC_PORTAL_URL` | `PORTAL_URL` |
|
|
33
|
+
| `RAYFIN_PUBLIC_SERVICE_MODE` | `VITE_SERVICE_MODE` | `NEXT_PUBLIC_SERVICE_MODE` | `SERVICE_MODE` |
|
|
34
|
+
|
|
35
|
+
Custom `RAYFIN_PUBLIC_*` variables you add follow a generic pattern: `RAYFIN_PUBLIC_FOO` becomes `VITE_RAYFIN_FOO` (Vite), `NEXT_PUBLIC_RAYFIN_FOO` (Next.js), or `FOO` (plain).
|
|
36
|
+
|
|
37
|
+
## Tooling overrides
|
|
38
|
+
|
|
39
|
+
These variables configure CLI and extension behavior.
|
|
40
|
+
They are not exposed to the frontend (no `PUBLIC_` infix).
|
|
41
|
+
Set them in `rayfin/.env` or as shell environment variables.
|
|
42
|
+
|
|
43
|
+
| Variable | Description | Default |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `RAYFIN_FABRIC_API_URL` | Fabric REST API base URL the CLI calls. For canonical Fabric hosts (`*.fabric.microsoft.com`) accepts a bare origin (e.g. `https://api.fabric.microsoft.com`) or an `<origin>/v1` URL — extra path segments are stripped to maintain back-compat. For non-Fabric hosts (proxies, custom envs) accepts an origin plus path prefix (e.g. `https://my-proxy.example.com/cli-proxy/fabric/<id>`); the path prefix is preserved verbatim and `/v1` is appended only when the resolved path does not already end in `/v1`. Independent — set on its own, with `RAYFIN_FABRIC_PORTAL_URL`, or with the full authentication group. | `https://api.fabric.microsoft.com/v1` |
|
|
46
|
+
| `RAYFIN_FABRIC_PORTAL_URL` | Fabric portal base URL used for deep links and `RAYFIN_PUBLIC_PORTAL_URL`. Independent — set on its own, with `RAYFIN_FABRIC_API_URL`, or with the full authentication group. | `https://app.fabric.microsoft.com/` |
|
|
47
|
+
| `RAYFIN_ENV_FILE` | Path to an alternate `.env` file. Equivalent to `--env-file`. | `rayfin/.env` |
|
|
48
|
+
|
|
49
|
+
When set on their own, the two Fabric endpoint variables apply only to the current process and are **not** persisted.
|
|
50
|
+
Subsequent CLI invocations need the same shell or `rayfin/.env` value to keep using the override.
|
|
51
|
+
|
|
52
|
+
Resolution precedence per variable: shell env var > value in `rayfin/.env` > persisted `environmentConfig` in `~/.rayfin/auth.json` > built-in default.
|
|
53
|
+
|
|
54
|
+
### Routing through a credential proxy
|
|
55
|
+
|
|
56
|
+
`RAYFIN_FABRIC_API_URL` accepts a non-Fabric origin with a path prefix on top, which lets you route the CLI's REST calls through a host that mounts the Fabric API under a sub-path (for example, a credential proxy that handles auth on the user's behalf).
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
export RAYFIN_FABRIC_API_URL="https://my-proxy.example.com/cli-proxy/fabric/<conn_id>"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For non-Fabric hosts, the CLI strips a trailing slash and appends `/v1` only when the resolved path does not already end in `/v1`, then composes the full request URL by appending `/workspaces/...` (and similar) to it.
|
|
63
|
+
With the example above, a workspaces lookup goes to `https://my-proxy.example.com/cli-proxy/fabric/<conn_id>/v1/workspaces/...`.
|
|
64
|
+
|
|
65
|
+
For canonical Fabric hosts (`*.fabric.microsoft.com`) the behavior is different: only the origin is honored and the path is replaced with `/v1`. This preserves the historical normalization for shapes like `https://api.fabric.microsoft.com/v1/workspaces/<id>` (which gets truncated back to `<origin>/v1` rather than producing a double-pathed result).
|
|
66
|
+
|
|
67
|
+
The portal URL is **not** auto-derived from a non-`*.fabric.microsoft.com` host, so when you target a proxy you typically also want to set `RAYFIN_FABRIC_PORTAL_URL` to the portal you want deep links and `RAYFIN_PUBLIC_PORTAL_URL` to point at — usually production:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
export RAYFIN_FABRIC_PORTAL_URL="https://app.fabric.microsoft.com/"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If your proxy also fronts the portal, point it there instead.
|
|
74
|
+
|
|
75
|
+
> **Security: bearer token forwarding.** When `RAYFIN_FABRIC_API_URL` points at a non-`*.fabric.microsoft.com` host, the CLI sends the Fabric `Bearer <token>` it acquired (whether for the production scope or a custom `RAYFIN_FABRIC_SCOPE`) to that host on every REST call. Only set this to a host you trust to handle those tokens responsibly — typically a first-party credential proxy you operate. There is currently no startup warning or trusted-host allowlist; that is a known follow-up.
|
|
76
|
+
>
|
|
77
|
+
> **Known limitation: long-running operations.** Operations that return a `202` with a `Location` header are a known limitation in proxy mode. The CLI follows the absolute URL in `Location`, which usually points back at the upstream Fabric host and bypasses your proxy. End-to-end proxy support for these polled operations needs the proxy to rewrite `Location` headers (or the CLI to grow a host-rewrite pass on the polling target). Track the follow-up before relying on proxy mode for long-running ops.
|
|
78
|
+
|
|
79
|
+
## Runtime port variables
|
|
80
|
+
|
|
81
|
+
Written to `rayfin/.env` by `rayfin up` during port allocation.
|
|
82
|
+
Each port starts at its default value and increments until a free port is found, so multiple projects can run side by side without conflict.
|
|
83
|
+
Read via `${VAR:-default}` interpolation in the generated container configuration.
|
|
84
|
+
|
|
85
|
+
| Variable | Default | Service | Docker profile |
|
|
86
|
+
| --- | --- | --- | --- |
|
|
87
|
+
| `RAYFIN_WEBSERVICE_HTTP_PORT` | 5168 | Rayfin WebService (HTTP) | always |
|
|
88
|
+
| `RAYFIN_WEBSERVICE_HTTPS_PORT` | 7126 | Rayfin WebService (HTTPS) | always |
|
|
89
|
+
| `RAYFIN_POSTGRES_PORT` | 5432 | PostgreSQL (admin database) | always |
|
|
90
|
+
| `RAYFIN_POSTGRES_DATAAPI_PORT` | 5433 | PostgreSQL (Data API backend) | `data-api-postgresql` |
|
|
91
|
+
| `RAYFIN_SQLSERVER_PORT` | 1433 | SQL Server (Data API backend) | `data-api-mssql` |
|
|
92
|
+
| `RAYFIN_MAILDEV_SMTP_PORT` | 1025 | MailDev SMTP | `email` |
|
|
93
|
+
| `RAYFIN_MAILDEV_WEB_PORT` | 1080 | MailDev web UI | `email` |
|
|
94
|
+
| `RAYFIN_AZURITE_BLOB_PORT` | 10000 | Azurite Blob | `storage` |
|
|
95
|
+
| `RAYFIN_AZURITE_QUEUE_PORT` | 10001 | Azurite Queue | `storage` |
|
|
96
|
+
| `RAYFIN_AZURITE_TABLE_PORT` | 10002 | Azurite Table | `storage` |
|
|
97
|
+
| `RAYFIN_FUNCTIONS_PORT` | 7071 | Azure Functions | `function` |
|
|
98
|
+
| `RAYFIN_ASPIRE_UI_PORT` | 18888 | Aspire Dashboard UI | `telemetry` |
|
|
99
|
+
| `RAYFIN_ASPIRE_OTLP_PORT` | 4317 | Aspire OTLP (gRPC) | `telemetry` |
|
|
100
|
+
|
|
101
|
+
Port variables are cleaned up from `rayfin/.env` when `rayfin up` shuts down.
|
|
102
|
+
|
|
103
|
+
## Database passwords
|
|
104
|
+
|
|
105
|
+
Written to `rayfin/.env` by `rayfin up`.
|
|
106
|
+
Passwords are generated on first run and preserved on subsequent runs so existing database volumes keep working.
|
|
107
|
+
Never exposed to the frontend.
|
|
108
|
+
|
|
109
|
+
| Variable | Default | Service |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| `RAYFIN_POSTGRES_PASSWORD` | `YourStrong!Passw0rd` | PostgreSQL (admin database) |
|
|
112
|
+
| `RAYFIN_SQLSERVER_PASSWORD` | `YourStrong!Passw0rd` | SQL Server |
|
|
113
|
+
| `RAYFIN_POSTGRES_DATAAPI_PASSWORD` | `YourStrong!Passw0rd` | PostgreSQL (Data API backend) |
|
|
114
|
+
|
|
115
|
+
## Service configuration flags
|
|
116
|
+
|
|
117
|
+
Written to `rayfin/.env` by `rayfin up` based on `rayfin.yml` settings.
|
|
118
|
+
Read by the Rayfin WebService container via the ASP.NET Core configuration system.
|
|
119
|
+
|
|
120
|
+
| Variable | Source (`rayfin.yml`) | Values |
|
|
121
|
+
| --- | --- | --- |
|
|
122
|
+
| `Auth__Enabled` | `services.auth.enabled` | `true` / `false` |
|
|
123
|
+
| `Data__Enabled` | `services.data.enabled` | `true` / `false` |
|
|
124
|
+
| `Storage__Enabled` | `services.storage.enabled` | `true` / `false` |
|
|
125
|
+
|
|
126
|
+
The following signing-key variables are set to dev-mode defaults by `rayfin up` and are not typically edited:
|
|
127
|
+
|
|
128
|
+
- `Auth__AsymmetricKeys__Provider` — `local-file`
|
|
129
|
+
- `Auth__AsymmetricKeys__Algorithm` — `ES256`
|
|
130
|
+
- `Auth__AsymmetricKeys__KeySize` — `256`
|
|
131
|
+
- `Auth__AsymmetricKeys__LocalFile__AutoGenerateKeys` — `true`
|
|
132
|
+
|
|
133
|
+
## Shell-only variables
|
|
134
|
+
|
|
135
|
+
These variables are read from the shell environment and are never written to files.
|
|
136
|
+
|
|
137
|
+
| Variable | Description |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `RAYFIN_TOKEN` | Pre-acquired Bearer token for headless or non-interactive usage. Bypasses interactive Entra ID login. Prefer `rayfin login --service-principal` which handles token acquisition automatically. Use `RAYFIN_TOKEN` when a token is already available from an external source (for example, `az account get-access-token`). |
|
|
140
|
+
| `RAYFIN_WORKSPACE_ID` | Fabric workspace ID for non-interactive setup. Used with `RAYFIN_TOKEN`. |
|
|
141
|
+
| `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). |
|
|
142
|
+
| `RAYFIN_ENCRYPTION_FALLBACK_ENABLED` | Set to `true` to allow plaintext token cache on systems without OS credential storage. Development only. |
|
|
143
|
+
| `RAYFIN_FEATURE_FLAGS` | Comma-separated list of experimental feature names to enable (case-insensitive). Recognized values include `storage`, `functions`, and `postgresql`. |
|
|
144
|
+
| `RAYFIN_APPINSIGHTS_CONNECTION_STRING` | Override the telemetry endpoint for the CLI and VS Code extension. |
|
|
145
|
+
|
|
146
|
+
### Recognized `RAYFIN_FEATURE_FLAGS` values
|
|
147
|
+
|
|
148
|
+
| Flag | Effect |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| `storage` | Exposes storage commands (`rayfin dev storage *`) and storage prompts during `rayfin init`. |
|
|
151
|
+
| `functions` | Exposes Functions service prompts during `rayfin init`. |
|
|
152
|
+
| `postgresql` | Adds PostgreSQL as a selectable dialect during `rayfin init` and `rayfin init` with bundled templates. |
|
|
153
|
+
|
|
154
|
+
## File locations
|
|
155
|
+
|
|
156
|
+
| Path | Purpose | Committed |
|
|
157
|
+
| --- | --- | --- |
|
|
158
|
+
| `rayfin/.env` | All runtime and deployment values. | No (gitignored) |
|
|
159
|
+
| `rayfin/.env.example` | Documents expected variables with placeholder values. | Yes |
|
|
160
|
+
| `rayfin/.deployments.json` | Multi-deployment registry (item IDs, API URLs, workspace IDs). | No (gitignored) |
|
|
161
|
+
| `rayfin/rayfin.yml` | Project configuration, service toggles, frontend framework. | Yes |
|
|
162
|
+
| `.env.local` | Framework-specific frontend variables, auto-generated by `rayfin env`. | No (gitignored) |
|
|
163
|
+
| `~/.rayfin/auth-state.json` | CLI authentication state (tenant, account hints). | N/A (user home) |
|
|
164
|
+
| `~/.rayfin/token-cache.json` | Encrypted token cache (OS-backed encryption). | N/A (user home) |
|
|
165
|
+
|
|
166
|
+
## Resolution priority
|
|
167
|
+
|
|
168
|
+
When the same variable is defined in multiple places, the value is resolved in this order (highest priority first):
|
|
169
|
+
|
|
170
|
+
1. Shell environment variable.
|
|
171
|
+
1. `--env-file <path>` CLI flag (or `RAYFIN_ENV_FILE`).
|
|
172
|
+
1. `rayfin/.env` file.
|
|
173
|
+
1. Default value (hardcoded or from `rayfin.yml` interpolation).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 40
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# CLI
|
|
6
|
+
|
|
7
|
+
Use the Rayfin CLI to scaffold projects, run local infrastructure, and apply schema changes.
|
|
8
|
+
|
|
9
|
+
## Get started
|
|
10
|
+
|
|
11
|
+
For installation instructions,
|
|
12
|
+
see [CLI Installation](./installation.md).
|
|
13
|
+
|
|
14
|
+
### Typical workflow
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm create @microsoft/rayfin@latest my-app # 1. Create a project from a template
|
|
18
|
+
cd my-app
|
|
19
|
+
npx rayfin up # 2. Start backend services
|
|
20
|
+
npm run dev # 3. Run the frontend dev server
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> **Existing or empty projects:** Use `npx rayfin init` instead of `npm create` to add Rayfin to a project that already has source code or an empty directory.
|
|
24
|
+
> The init command walks you through enabling services, choosing a database dialect, and configuring static hosting without scaffolding a new template.
|
|
25
|
+
|
|
26
|
+
For the full walkthrough, see the [CLI Quickstart](./quickstart.md) or the [Build and deploy tutorial](../getting-started/create-app-with-cli.md).
|
|
27
|
+
|
|
28
|
+
## Command reference
|
|
29
|
+
|
|
30
|
+
### Project scaffolding
|
|
31
|
+
|
|
32
|
+
| Command | Description |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `npm install --save-dev @microsoft/rayfin-cli` | Install the Rayfin CLI as a dev dependency. Not needed if you scaffolded with `npm create @microsoft/rayfin@latest`. |
|
|
35
|
+
| `npm create @microsoft/rayfin <name>` | Scaffold a new project from a template. Use `-t, --template <name>` to skip the interactive prompt or `--list-templates` to see available templates. |
|
|
36
|
+
| `npx rayfin init [directory]` | Initialize a new Rayfin project interactively. Prompts for project name, services (Auth, Data), and auth methods. Creates the `rayfin/` directory with starter files. |
|
|
37
|
+
| `npx rayfin init ai-files install` | Install or refresh the [agent context files](./ai-files.md) (`AGENTS.md`, `.mcp.json`, `.agents/skills/rayfin/SKILL.md`) so coding agents know how to work with your project. Idempotent; auto-runs as part of the scaffold pipeline. |
|
|
38
|
+
| `npx rayfin init ai-files status` | Print the current state of each agent file. Add `--json` for machine-readable output. |
|
|
39
|
+
|
|
40
|
+
> **Reconfiguring an existing project:** Running `npx rayfin init` in a project that already has a `rayfin/rayfin.yml` re-runs the interactive prompts and regenerates the configuration.
|
|
41
|
+
> Use this to enable or disable services, switch the database dialect, or toggle static hosting without editing `rayfin.yml` by hand.
|
|
42
|
+
> The CLI preserves your data model files under `rayfin/data/` during reconfiguration.
|
|
43
|
+
|
|
44
|
+
### Deployment
|
|
45
|
+
|
|
46
|
+
| Command | Description |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `npx rayfin login` | Sign in with Entra ID for remote Fabric operations. The CLI stores auth state under `~/.rayfin/` and uses the OS keychain for token storage when available. Use `-t, --tenant <id>` to provide your Tenant ID for Fabric sign-in. Add `--select` to always show the MSAL account picker, ignoring any cached account. 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. |
|
|
49
|
+
| `npx rayfin login --service-principal` | Sign in as a service principal using client credentials. Requires `--client-id <id>`, `--client-secret <secret>`, and `-t, --tenant <id>`. Credentials are persisted so subsequent commands authenticate automatically. |
|
|
50
|
+
| `npx rayfin login status` | Show the current sign-in status (account and tenant). |
|
|
51
|
+
| `npx rayfin logout` | Sign out and clear cached auth state. |
|
|
52
|
+
| `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. |
|
|
53
|
+
| `npx rayfin up status` | Display the status of the Fabric deployment (add `--json` for machine-readable output). |
|
|
54
|
+
| `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. |
|
|
55
|
+
| `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. |
|
|
56
|
+
|
|
57
|
+
## Update the CLI
|
|
58
|
+
|
|
59
|
+
To get the latest version of the Rayfin CLI and its dependencies:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm update --save
|
|
63
|
+
npm install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Verify the installed version:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx rayfin --version
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Telemetry
|
|
73
|
+
|
|
74
|
+
The Rayfin CLI collects anonymous usage data to help improve the product.
|
|
75
|
+
On the first run, the CLI displays a notice explaining what is collected and how to opt out.
|
|
76
|
+
|
|
77
|
+
No personal data, parameter values, or file contents are collected.
|
|
78
|
+
Only command names, execution status, execution duration, and environment metadata (OS, Node.js version) are recorded.
|
|
79
|
+
|
|
80
|
+
To disable telemetry, set the following environment variable:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
export RAYFIN_TELEMETRY_OPTOUT=1
|
|
84
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 0
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# CLI Installation
|
|
6
|
+
|
|
7
|
+
The Rayfin CLI (`@microsoft/rayfin-cli`) scaffolds projects,
|
|
8
|
+
runs local infrastructure, and deploys to Microsoft Fabric.
|
|
9
|
+
This page covers how to install it and verify it is working.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- [Node.js](https://nodejs.org/) 20 or later
|
|
14
|
+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
|
15
|
+
(or Docker Engine on Linux) for local development
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### New project
|
|
20
|
+
|
|
21
|
+
Scaffold a project from a template.
|
|
22
|
+
This installs the CLI automatically as a dev dependency:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm create @microsoft/rayfin@latest my-app
|
|
26
|
+
cd my-app
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Existing project
|
|
30
|
+
|
|
31
|
+
If you already have a project and want to add Rayfin,
|
|
32
|
+
install the CLI as a dev dependency first:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install --save-dev @microsoft/rayfin-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then run the interactive setup to create the `rayfin/`
|
|
39
|
+
directory with starter configuration files:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx rayfin init
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Verify the installation
|
|
46
|
+
|
|
47
|
+
Confirm the CLI is available and check the installed version:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx rayfin --version
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You should see the version number printed to the terminal.
|
|
54
|
+
|
|
55
|
+
Run `npx rayfin --help` to list all available commands:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx rayfin --help
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## First steps
|
|
62
|
+
|
|
63
|
+
Start the backend services:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx rayfin up
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This launches the enabled services,
|
|
70
|
+
runs health checks, and applies the database configuration.
|
|
71
|
+
Wait for the deployment to complete before continuing.
|
|
72
|
+
|
|
73
|
+
Apply schema changes after updating your data models:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx rayfin up db apply
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Run your frontend dev server in a separate terminal:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm run dev
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Update the CLI
|
|
86
|
+
|
|
87
|
+
To get the latest version:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm update --save
|
|
91
|
+
npm install
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Verify the update:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx rayfin --version
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Next steps
|
|
101
|
+
|
|
102
|
+
- [CLI Quickstart](./quickstart.md) for a full walkthrough
|
|
103
|
+
of creating, developing, and deploying a project.
|
|
104
|
+
- [CLI command reference](./index.md) for the complete
|
|
105
|
+
list of commands and options.
|
|
106
|
+
- [Build your first Rayfin app](../getting-started/create-app-with-cli.md)
|
|
107
|
+
for a step-by-step tutorial.
|