Rayfin

Deployment pipelines

Prepare Rayfin apps for Microsoft Fabric Deployment Pipelines by resolving runtime config instead of baking stage values into the bundle.

Fabric Deployment Pipelines promote a pre-built Fabric AppBackend between stages. The source bundle is not rebuilt, so a Rayfin frontend must read stage-specific backend config at runtime.

What moves between stages

A promoted AppBackend definition contains pre-built artifacts:

MyAppBackend.AppBackend/
├── .platform
├── rayfin.yml
├── dab-config.json
└── static-app.zip

The static bundle moves byte-for-byte. Stage-specific values such as API URL, publishable key, workspace ID, item ID, portal URL, and tenant ID are regenerated for the target stage as rayfin.config.json beside the static assets.

Resolve config before creating the client

Changed in 2.0

Use resolveRayfinConfig() from @microsoft/rayfin-client, then pass its result to RayfinClient.create. Pass build-time env vars as local-dev defaults; deployed stages override them from rayfin.config.json.

src/rayfinClient.ts
import { RayfinClient, resolveRayfinConfig } from '@microsoft/rayfin-client';
import { browserSession } from '@microsoft/rayfin-auth';
import { dataService } from '@microsoft/rayfin-data';
import type { AppSchema } from '../rayfin/data/schema';

export async function createClient() {
  const resolved = await resolveRayfinConfig({
    apiUrl: import.meta.env.VITE_RAYFIN_API_URL,
    publishableKey: import.meta.env.VITE_RAYFIN_PUBLISHABLE_KEY,
    workspaceId: import.meta.env.VITE_FABRIC_WORKSPACE_ID,
    itemId: import.meta.env.VITE_FABRIC_ITEM_ID,
    portalUrl: import.meta.env.VITE_FABRIC_PORTAL_URL,
    tenantId: import.meta.env.VITE_FABRIC_TENANT_ID,
  });

  return RayfinClient.create({
    baseUrl: resolved.baseUrl!,
    publishableKey: resolved.publishableKey!,
    runtimeConfig: resolved.runtimeConfig,
    auth: browserSession({ storage: true }),
    services: { data: dataService<AppSchema>() },
  });
}

export type AppClient = Awaited<ReturnType<typeof createClient>>;

The app installs @microsoft/rayfin-auth and @microsoft/rayfin-data itself; register other services, such as functionsService or storageService, in the same services object. In 1.x the snippet called new RayfinClient<AppSchema>({ ...resolved, authStorage: true }); that constructor was removed in 2.0. Removed in 2.0

Do not call RayfinClient.create with VITE_RAYFIN_API_URL and VITE_RAYFIN_PUBLISHABLE_KEY directly in deployed code. That bakes the source stage into the bundle. To find client construction that skips resolveRayfinConfig(), search for:

grep -rn "RayfinClient.create" src/

Read Fabric coordinates from runtimeConfig

Fabric auth and embedded flows also need workspace, item, portal, and tenant values. Read them from client.runtimeConfig after resolving config; do not read VITE_FABRIC_* directly in promoted code.

src/fabricAuthOptions.ts
import type { FabricAuthOptions } from '@microsoft/rayfin-auth-provider-fabric';
import type { AppClient } from './rayfinClient';

export function fabricAuthOptions(client: AppClient): FabricAuthOptions {
  const { workspaceId, itemId, portalUrl, tenantId } = client.runtimeConfig ?? {};
  if (!workspaceId || !itemId || !portalUrl) {
    throw new Error('Fabric coordinates are missing from the resolved runtime config.');
  }
  return {
    workspaceId,
    projectId: itemId,
    fabricPortalUrl: portalUrl,
    tenantId,
    returnOrigin: window.location.origin,
  };
}

Pass the result to ensureSignedInWithFabric or initEmbeddedAuth from @microsoft/rayfin-auth-provider-fabric. tenantId is optional; when it is set, the Fabric sign-in page opens directly in that tenant instead of discovering the user's home tenant first. New in 2.0

Read the Application Insights connection string

New in 2.0 Experimental

For an app with services.telemetry.enabled: true, the rayfin.config.json generated for each stage includes that stage's applicationInsightsConnectionString. It is omitted when telemetry is disabled or no connection string has been allocated.

src/telemetryConfig.ts
import type { AppClient } from './rayfinClient';

export function applicationInsightsConnectionString(client: AppClient): string | undefined {
  return client.runtimeConfig?.applicationInsightsConnectionString;
}

The client only exposes the value; it does not start telemetry. Do not pass a source-stage connection string to resolveRayfinConfig() as a default in a promoted app, or a target stage without telemetry falls back to the source stage's destination. See Observability for setup.

Warning

Observability is experimental. The connection string appears only after Fabric service-side telemetry enablement allocates a resource, and only when server-side runtime-config generation is enabled for static deployments.

What is not promoted this way

  • Secrets remain separate from deployment-pipeline promotion.
  • Source-code Git integration is a Fabric platform feature, not a Rayfin CLI deploy.
  • Functions have their own deployment behavior; validate them separately in each stage.
PromptMake my Rayfin frontend deployment-pipeline safe
My frontend uses Rayfin 2.0. Search src/ for `RayfinClient.create` calls and for direct `VITE_FABRIC_*` reads. Make every client resolve its configuration first: call `resolveRayfinConfig()` from @microsoft/rayfin-client with the current VITE_RAYFIN_API_URL, VITE_RAYFIN_PUBLISHABLE_KEY, and VITE_FABRIC_* values as defaults, then pass `baseUrl`, `publishableKey`, and `runtimeConfig` from the result into `RayfinClient.create` alongside the existing `auth` and `services`. Replace direct `VITE_FABRIC_*` reads with `client.runtimeConfig` (workspaceId, itemId, portalUrl, tenantId) so a promoted Fabric Deployment Pipeline stage uses that stage's generated rayfin.config.json. If you find a 1.x `new RayfinClient(...)` constructor, replace it with `RayfinClient.create` and `browserSession({ storage: true })` from @microsoft/rayfin-auth.
Something wrong on this page?Report an issueEdit this page

On this page