Fabric App Functions: Call a Data Agent Without an App Registration
The hard part of embedding a data agent was never the chat box. It was the backend: somewhere to keep the token, an app registration, a secret to rotate. Fabric Apps functions, announced at FabCon Europe, collapse that into a few lines of TypeScript that run as the app itself. Here is how they work, and the design rule that makes them useful: agents answer, functions act.
Every embedded data agent I have built had the same shape: a browser, a small backend that holds a secret, and the agent behind it. The browser part takes an afternoon. The backend is where the weeks go: an app registration, a client secret, a vault, a rotation schedule, a host for the proxy, and a security review for all of it. Fabric app functions remove most of that list.
Fabric Apps arrived in preview at Build in June: an application backend on Fabric, defined in TypeScript with the open-source Rayfin SDK and CLI, deployed with one command. At FabCon Europe this week, Microsoft added the two pieces that make it interesting for data agents: server-side functions and connectors to Fabric data. This post is about the functions, and specifically about one pattern: calling the data agent MCP endpoint from a function, as the app, with no credentials in your code.
- 0 app registrations and secrets. The function gets a Fabric token for the app's own identity from its context. There is nothing to create, store, or rotate.
- 1 deploy command.
rayfin upships the frontend, the database schema, and the functions together, as one Fabric item. - 2 identities to keep straight. The app's identity for Fabric resources, and the signed-in user's for the app's own data. Most of the design follows from that split.
What a Fabric App Is
A Fabric app is a single item in a workspace that bundles a backend and a frontend. You describe it in code and in a rayfin.yml file; rayfin up creates the pieces as child items:
A SQL database and GraphQL API
You write TypeScript classes with decorators like @entity() and @role(). Rayfin turns them into tables, a GraphQL API, row-level rules, and a typed client.
Fabric sign-in
Deployed apps use Fabric SSO (Microsoft Entra ID) only. Users open the app with their normal Fabric identity; you share it with the item permission Run and interact.
Static hosting
Your built React (or any) frontend, served from a Fabric hosting URL, protected by default.
Functions and connectors (new)
TypeScript functions that run server-side in the Fabric runtime, and typed connectors to a lakehouse, warehouse, SQL database, or semantic model.
Everything here is in preview, a tenant admin has to enable the Fabric Apps (preview) setting, and it is not in every region yet. Check the current docs before you plan around a specific command; the CLI is moving quickly.
Functions in One Screen
A function is a named handler registered with udf.func() in rayfin/functions/src/function_app.ts. Typegen reads your signatures and generates a typed client, so the frontend calls it like a local method. Enable functions with application auth in rayfin.yml:
Inside a handler, the last parameter is the context. Two things on it matter for this post:
| On the context | Runs as | Use it for |
|---|---|---|
ctx.Tokens.Fabric (also Sql, Storage, AzureAI, ADO) |
The app identity | Calling Fabric and Azure resources, including data agents |
ctx.getDataClient() |
The calling user | Reading and writing the app's own database, subject to its @role rules |
You declare which tokens a function needs in the type of its context parameter, for example RayfinContext<AppSchema, AudienceType.Fabric>. The annotation is what registers the binding, which is why the third argument to udf.func() stays an empty array. Secrets, when you do need one for a non-Fabric API, are declared with rayfin secret set and read from ctx.Secrets, never from the frontend.
Calling a Data Agent from a Function
Put the two posts together and the function almost writes itself. The browser sends an agent key and a question. The function looks up the agent's MCP URL on the server, gets a Fabric token for the app, runs the four MCP messages, and returns only the answer:
And from the React side, the generated client makes it one call:
Notice what the browser never sees: the agent URL, the workspace ID, the token. It sends a short key like sales and gets back text. The agent URLs are not secrets on their own (a caller still needs a token and access), but keeping them on the server means the allowlist of agents this app may call is enforced in one reviewable file.
Follow One Question
Here is the same function from the outside: one question, from the moment the user presses Enter to the row on the action board.
The browser sends a key and a question
Not a URL, not a token. Just sales and the text the user typed. That is all the client is trusted with.
The function gets a token for the app
ctx.Tokens.Fabric is a Fabric token for the app's own identity. It never leaves the server. The function also looks the agent's MCP URL up in its own allowlist.
The agent answers with the owner's access
Four MCP messages later, the agent plans and runs its queries against the lakehouse, with the app owner's permissions, for every user.
Only the answer comes back
The function returns text and tables, plus a label saying who answered. The token, the URL, and the workspace stay on the server.
A button turns the answer into an action
“Follow up” calls a second function. It applies the priority and due-date rules on the server and writes one row to the app's database, as the signed-in user. The agent never writes anything.
What "As the App" Means
The app identity is tied to the owner of the app item. When a function calls a data agent with ctx.Tokens.Fabric, every user's question runs with the owner's permissions on the agent's data. This is the same trade-off I described for service principals in the MCP post, with the operational burden removed. So the same two rules apply:
- Scope each agent to data every app user may see, or publish one agent per audience and decide on the server which agents a user may call.
- Say so in the UI. A small "answered as the app" label next to each answer costs nothing and prevents a user from assuming an answer reflects their own access.
The owner (the app identity) needs access to each agent and Read on each agent's data sources. Users of the app need only Run and interact on the app item. If you also use a connector in delegated mode for charts, users need read access to that data source as well, because those queries run as them.
Agents Answer, Functions Act
Here is the design rule I would put on a poster. A data agent is a reader. It is very good at turning a question into a correct query and a clear answer. It should not create records, change priorities, or decide what happens next. That is what functions are for.
In practice, an answer comes back with buttons next to it: create a follow-up, escalate, build a recovery plan. Each button calls a function. The function takes the facts from the answer, applies the business rules on the server, and writes a row to the app's database. The agent never writes anything, and the browser never decides anything that matters.
The table behind it is a Rayfin entity, and its permission decorators finish the job. Users may read and create action items, but the only field they may update directly is status. Priority, due date, owner, and amounts are set once, by the function's rules:
One honest limit: because getDataClient() runs as the calling user, that user also holds create on the table and could, in principle, create a row through the GraphQL API directly, skipping your rules. For an internal action board that is an acceptable risk. For anything with financial or compliance weight, keep the rules in the function and validate again wherever the data is consumed.
Things That Will Bite You
The 240-second ceiling
Functions stop at 240 seconds. Most agent answers take 10 to 60, but a cold, complex question can run long. Pass a generous timeoutMs on invoke, show a pending state, and give users a way to retry.
Annotate the context inline
Write ctx: RayfinContext<AppSchema, AudienceType.Fabric> directly on the parameter. In my build, hiding it behind a type alias made typegen treat the context as a request parameter, and every call failed with MissingInput.
Empty parameters are rejected
The functions runtime rejects empty string arguments. For optional values, send a sentinel such as "-" from the browser and normalize it in the function.
Anything from the browser is untrusted
If you round-trip state through the client (a conversation id, a session id), validate every field against a strict pattern before it reaches a URL or header, and start fresh if it fails.
Use import type for entities
A runtime import of an entity class pulls the decorator runtime into the functions bundle. Import the type, or keep a structural copy of the row shape in the functions project.
It is a preview
Commands, flags, and package names have changed between releases. Read the docs that ship inside the installed Rayfin packages, which match your version, before trusting a blog post. Including this one.
Why This Changes Embedded Analytics
Before functions, "embed a data agent" meant standing up infrastructure outside Fabric and accepting the governance work that came with it. Now the agent, the data, the app, and the server-side logic that joins them all live in one workspace, behind one sign-in, deployed by one command. The identity question does not go away, but the answer to it is a single, visible owner instead of a secret in a vault.
The final post in this series puts all of it together: live charts through a connector, a team of agents through functions, and actions that close the loop, in one app.
Further Reading
- What is Fabric Apps (Preview)?: Microsoft Learn overview, permissions, and prerequisites
- Connect Fabric Apps to Fabric data: connector types, operations, and delegated auth
- Calling a Fabric Data Agent over MCP: the protocol this function speaks
- What's New in Fabric Data Agents: the start of this series