Back to posts
Part 1 of 6 · Fabric Data Agents in Your Apps
May 26, 2026•7 min read

Service Principal Authentication for Fabric Data Agents

Fabric Data Agents now support service principal authentication: the missing piece for taking AI-powered data agents from prototype to production without depending on user sign-in flows.

Update, September 22, 2026

The client code in this post uses the OpenAI Assistants-style endpoint (/aiassistant/openai), and OpenAI shut down the Assistants API on August 26, 2026. Microsoft now points to each published agent's MCP endpoint instead. The service principal setup below still applies: the same token works as a bearer header on the MCP endpoint. For the new client code, see Calling a Fabric Data Agent over MCP.

Until now, every call to a Fabric Data Agent API required a delegated user token. A real person had to sign in. That works for interactive demos but breaks the moment you try to wire a data agent into a backend service, a scheduled job, or a multi-user chatbot. Service principal support changes that. Your application authenticates on its own behalf, no user sign-in required.

This feature, currently in public preview, is one of the most-requested capabilities from teams moving Fabric Data Agents into production. Here is what changed, why it matters, and how to set it up.

  • 0 user sign-ins needed. Service principals authenticate with application credentials. No interactive login flow, no token pop-ups, no dependency on a human session.
  • 2 key production scenarios. Direct app-to-agent calls and Microsoft Foundry agent integration: both now work with application-level identity.
  • ~1h access token lifetime. Client-credentials access tokens expire after roughly 60 to 90 minutes. The OAuth 2.0 client-credentials flow requests fresh ones automatically. The client secret itself rotates on the schedule you configure.

The Problem Before

Fabric Data Agents expose a conversational API that lets applications send natural-language questions and receive grounded answers from enterprise data. But the authentication model only supported delegated user tokens: the OAuth 2.0 authorization-code flow where a real user signs in.

This blocked three patterns

  • Backend services: APIs, cron jobs, and microservices that run without a browser session
  • Multi-user chatbots: a single bot serving many end-users shouldn't need each user to have Fabric access
  • Agent-to-agent orchestration: Foundry agents calling Fabric data agents as tools in an agentic workflow

Two Production Scenarios

Scenario 1: Custom App → Data Agent

You have built a Fabric data agent, published it, and want to call it from your own application: a web app, a backend service, a chatbot, or an internal tool. Your app authenticates with its own service principal credentials, gets a token from Entra ID, and calls the data agent API directly.

The application acts on its own behalf. End-users never need Fabric access.

Scenario 2: Foundry Agent → Data Agent

You build an agent in Microsoft Foundry and connect a Fabric data agent as a knowledge source or tool. The Foundry agent handles conversational experience and orchestration logic, while the Fabric data agent provides grounded, accurate answers from enterprise data.

The Foundry agent authenticates to the data agent via service principal, with no user pass-through needed.

Setup in Four Steps

1

Register an app in Microsoft Entra ID

Go to the Azure portal → App registrations → New registration. This creates the application identity your service will use.

2

Create a service principal and secret

The service principal is the identity object in your tenant. Generate a client secret (or certificate) that your application will use to authenticate.

3

Grant workspace access

Add the service principal to your Fabric workspace with the appropriate role. The data agent inherits workspace permissions, with no separate agent-level grant needed.

4

Authenticate and call the API

Use the OAuth 2.0 client-credentials flow to request a token from Entra ID, then call the data agent API with that bearer token.

Authentication Flow

# Python: acquire token and call Fabric Data Agent API
import os
from azure.identity import ClientSecretCredential
from openai import OpenAI
# 1. Authenticate with service principal
# Credentials come from the environment, never hardcode a client secret
credential = ClientSecretCredential(
tenant_id=os.environ["TENANT_ID"],
client_id=os.environ["CLIENT_ID"],
client_secret=os.environ["CLIENT_SECRET"]
)
# 2. Get access token for Fabric API
token = credential.get_token("https://api.fabric.microsoft.com/.default")
# 3. Call the data agent; its published endpoint is OpenAI Assistants-compatible
workspace_id = "YOUR_WORKSPACE_ID" # from the workspace URL
agent_id = "YOUR_AGENT_ID" # the data agent's item ID
base_url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/aiskills/{agent_id}/aiassistant/openai"
client = OpenAI(api_key="unused", base_url=base_url,
default_headers={"Authorization": f"Bearer {token.token}"})
assistant = client.beta.assistants.create(model="not-used")
thread = client.beta.threads.create()
client.beta.threads.messages.create(thread_id=thread.id, role="user",
content="What were total sales last quarter?")
run = client.beta.threads.runs.create(thread_id=thread.id, assistant_id=assistant.id)
# poll run status, then read the thread's messages for the answer

The data agent API surface has evolved during preview. Verify the current endpoint shape against the Microsoft Learn reference before shipping.

Gotchas and Best Practices

Bootstrap the security token first

Newly created service principals must generate an initial Fabric security token via the Fabric REST API. Until you do this, you will see cryptic errors about missing files or permissions, even though the SPN has been granted access.

Enable SPN access in admin portal

The Fabric admin portal has a tenant setting that must explicitly allow service principals to call Fabric APIs. Without this toggle, all SPN calls return 403 regardless of workspace permissions.

Token refresh vs. secret rotation

Access tokens from the client-credentials flow live roughly 60 to 90 minutes. Libraries like azure-identity refresh them for you. What expires on a longer schedule is the client secret (typically months, set at creation): track it and rotate before expiry, and never rely on manual renewal.

KQL databases coming soon

Service principal support for KQL databases as a data agent source is not yet available but has been confirmed as coming soon. Plan accordingly if your agent queries Eventhouse data.

Try It Yourself: Interactive Testing Template

Before writing a single line of production code, verify your service principal configuration works. We built an open-source template that lets you test the full SPN → Data Agent flow right in your browser, with no local setup required.

Three-Step Test

  1. Create & publish your Data Agent in Microsoft Fabric
  2. Enter credentials: Tenant ID, Client ID, Client Secret, and Data Agent API URL
  3. Hit Test Connection: query your data agent with natural language, live

The template uses the official Fabric Data Agent REST API with the client-credentials flow. Conversation memory is retained across turns so you can explore multi-step questions. It generates drop-in embed code you can copy straight into your app.

Perfect For

  • Validating SPN config before writing production code
  • Learning the authentication flow hands-on
  • Demoing data agent capabilities to stakeholders
  • Rapid proof-of-concept without local environment setup

Testing only: use a throwaway service principal

This form takes a client secret in the browser, which is exactly what production code must never do. Use a development service principal scoped to a non-production workspace, and rotate or delete the secret as soon as you finish testing. Never paste production credentials here. In a real application the secret stays on your backend. See embedding a Data Agent in your own app for the proxy pattern.

Why This Matters for Enterprise Teams

Service principal auth unlocks the governance model enterprises need. Application-level identities are auditable, manageable by security teams, and don't expose user credentials in backend services. Combined with workspace-level permissions inheritance, you get fine-grained access control without a separate permission layer for each data agent.

This also plays into the broader Agentic Fabric vision, where MCP servers, deployment pipelines, and job schedulers all authenticate via service principal. The data agent support is one piece of a larger shift toward headless, automated Fabric workflows.

Further Reading

Tags

Microsoft FabricAIData AgentsSecurityService PrincipalAuthentication