Why this is an identity problem, not a connector problem
You can connect a Snowflake Cortex Agent to Microsoft Agent 365 and Microsoft Entra Agent ID so that every Snowflake query runs as a known identity, with the right roles and no stored passwords or client secrets. I built this end to end: an agent in Microsoft Teams and Microsoft 365 Copilot that answers sales questions from Snowflake. This article covers what I learned about identity, access, federation and trust along the way.
Getting a chat message to call the Cortex Agents REST API is the easy part. The hard part is answering two questions in a way a security team will sign off on:
- Who is the agent acting as? Is it acting for a signed-in user (on-behalf-of, OBO), or on its own as an autonomous agent with no user present?
- What can it reach in Snowflake, and who decides? Should Entra decide the role, should Snowflake, or should both?
Everything below follows from those two answers: which token flow you use, which Snowflake integration trusts which issuer, how roles are scoped, and how you shut the agent off when you need to.
The trust chain at a glance

Every call into Snowflake goes through one agent identity, by either External OAuth or inbound WIF. The coloured arrow is the reverse path, where Snowflake’s own token becomes an Entra client assertion.
Trust from Entra to Snowflake: two doors
Snowflake can trust Entra tokens in two ways. They solve different problems, and I ended up using both.
| External OAuth integration | Workload Identity Federation (WIF), inbound | |
|---|---|---|
| What Snowflake trusts | Entra-issued access tokens for a Snowflake resource app you register | Entra tokens issued for Snowflake’s own WIF app (api://fd3f753b-…) |
| Identity mapping | A token claim (for example upn) to a Snowflake user attribute | The token’s sub to a Snowflake user created with WORKLOAD_IDENTITY |
| Roles | From the token’s scopes or roles, intersected with Snowflake grants | The user’s Snowflake default role |
| Best for | OBO: a person’s identity and Entra-governed roles | Autonomous agents: no secret, no user |
| Request header | Authorization: Bearer <token> | Authorization: Bearer WIF.AZURE.<token> |
A few settings on the External OAuth integration matter more than they look:
- Turn off any-role (
EXTERNAL_OAUTH_ANY_ROLE_MODE = DISABLE) so a token can’t ask for a role it wasn’t issued. - Block privileged roles. ACCOUNTADMIN, SECURITYADMIN and ORGADMIN stay on the blocked list. In testing, a token scoped to a regional role could not open an ACCOUNTADMIN session (error
390317). - Map on a stable claim. I mapped
upnto the SnowflakeLOGIN_NAME, which SCIM provisioning keeps in step.
WIF is documented by Snowflake for Azure managed identities. In my build it also accepted an Entra Agent ID agent identity token (v2 issuer, sub = the agent identity’s ID). That is observed behaviour, not documented support, so confirm it with Snowflake before relying on it. External OAuth is the documented fallback.
On-behalf-of agents: the user’s identity, the agent’s guardrails
When a person asks the agent a question in Teams, the Snowflake session runs as that person, and the agent can never do more than the person could. Entra Agent ID makes this a three-step exchange with no client secret:
- Blueprint to agent identity. The agent’s hosting compute uses its managed identity to get a token for the agent blueprint. It then asks for an agent identity token, using
fmi_pathto name the agent identity. Every agent instance has its own identity, and it is the agent identity, not the blueprint, that holds permissions. - User token to OBO token. The agent identity exchanges the user’s incoming token with the
jwt-bearergrant for a token scoped to the Snowflake resource app. That token carries the user’supnand the scopes the user consented to for the agent. - OBO token to Snowflake. Snowflake’s External OAuth integration validates the token, maps
upnto the Snowflake user, and opens a session.
The important line is what role the session gets. I found it easiest to reason about as an intersection:
Effective role = roles in the token ∩ roles granted to the Snowflake user
If the token names a role the user hasn’t been granted, the session fails. If the user has a role the token doesn’t name, the agent can’t use it. Two more settings close the gaps:
- A session policy with
ALLOWED_SECONDARY_ROLES = ()stops secondary roles from quietly widening what the agent sees. - An explicit
DEFAULT_ROLEandDEFAULT_SECONDARY_ROLESon agent-facing users, so nothing depends on account defaults.
I tested two modes. In strict mode, any-role is off. The agent asks for one session:role:<ROLE> scope per agent-facing role, and Snowflake keeps only the role the user’s groups grant. In Snowflake-decides (role-any) mode, the token caps only the primary role. Secondary roles were still activated, and USE SECONDARY ROLES ALL succeeded. Prefer strict mode. If you need role-any, add the session policy above and an explicit default role.
Autonomous agents: their own identity, nobody’s password
An autonomous agent, such as a scheduled report or an event-driven workflow, has no user to act for, so it gets its own Snowflake user and a tightly scoped role. The agent identity requests an app-only token (client_credentials) through the same blueprint chain, with no secret anywhere.
On the Snowflake side I treated these identities as non-human from the start:
TYPE = SERVICE_AGENTusers. They can’t sign in interactively or use a password, and they show up as agents in audit queries.IS_AGENTIC = TRUEon the integration, so agent-aware policies can tell agent sessions from human ones.- One read-only role per agent. It covers only the schemas the agent needs and has its own warehouse with a resource monitor.
For the trust itself you can use either door. With External OAuth, the app-only token carries an Entra app role that maps to the Snowflake role. With inbound WIF, Snowflake maps the agent identity’s sub directly to the SERVICE_AGENT user. WIF gives the cleanest result: no client secret in Entra and no key pair in Snowflake.
Agent 365 can also sync Snowflake Cortex Agents into its registry as a connected platform, so they appear next to your other agents. Today that is inventory, not control. Synced agents show as Unmanaged and can’t be assigned an owner, so access control still lives in the Entra and Snowflake configuration above.
The other direction: Snowflake calling into Entra
Trust can also run the other way. Snowflake can call Microsoft services with no secret stored in Snowflake and none on the Entra app, using outbound workload identity federation. I proved the full round trip: the agent signed in to Snowflake over inbound WIF, Snowflake issued its own token, and Entra exchanged that token for a Microsoft Graph app token.
It takes three pieces:
- A Snowflake secret of type WIF.
CREATE SECRET … TYPE = WORKLOAD_IDENTITY_FEDERATIONdefines the identity.DESC SECRETshows the issuer (https://identity.snowflake.com/oauth2/…) and the subject (identity_<hash>) that Snowflake will put in its tokens. - A federated identity credential on a dedicated Entra app. Use the Other issuer option, paste the issuer and subject exactly, and set the audience to
api://AzureADTokenExchange. The app has no secret or certificate. - The exchange. Inside Snowflake,
SYSTEM$ISSUE_WORKLOAD_IDENTITY_FEDERATION_TOKEN('<secret>', '{"aud":"api://AzureADTokenExchange"}')returns a 15-minute token. Send it to Entra as theclient_assertionin aclient_credentialsrequest.
Two details cost me time:
- The audience must match exactly. A token with the wrong
audis rejected withAADSTS700212, which is the negative test you want to see. - New federated credentials take about a minute to propagate. Until then Entra returns
AADSTS70025, so retry rather than debug.
The control point is USAGE on the Snowflake secret. Whoever can use the secret can mint tokens as that Entra app, so grant it only to the role that needs it, and give the Entra app only the permissions that workload needs. Snowflake documents outbound WIF and its use with Azure services such as Key Vault and Blob Storage, some of it in preview. Using the token directly as an Entra client assertion is standard Entra federation, but check current Snowflake guidance for your scenario.
What you need before you start
| Requirement | Notes |
|---|---|
| Microsoft 365 tenant with Agent 365 | Entra Agent ID needs an Agent 365 (or qualifying Microsoft 365 Copilot) license. Check current enrollment requirements on Microsoft Learn. |
| Entra roles | Agent ID Developer or Agent ID Administrator for the blueprint. Application Administrator or Global Administrator for app registrations, app roles and admin consent. |
| Azure subscription | For the agent host and the managed identity that backs the blueprint’s federated credential. |
| Snowflake account | Enterprise edition or higher, for row access and masking policies, in a region with Cortex Agents and Cortex Analyst. Cortex Agents REST needs a paid account, not a trial. |
| Teams and Copilot (optional) | An Azure Bot resource, permission to upload a custom app in the Teams admin center, and Microsoft 365 Copilot licenses for the Copilot channel. |
Tools: the Agent 365 CLI (a365), Azure CLI or Microsoft Graph PowerShell, Snowsight or SnowSQL, and the Microsoft 365 Agents SDK.
The build order that worked for me:
- Register the agent with
a365 setup all, then move the blueprint to a managed identity federated credential and delete any client secret. - Create the Snowflake resource app in Entra, with one delegated
session:role:<ROLE>scope per agent-facing role and app roles for autonomous agents. - Grant those scopes and app roles to the agent identity, not to the blueprint.
- In Snowflake, create the agent-facing roles, policies and the External OAuth integration.
- Provision users and groups with SCIM, and map each Entra group to a role that inherits the agent-facing role.
- Create one
SERVICE_AGENTuser per autonomous agent. - Build and host the agent, then deliver it to Teams and Copilot.
- Add governance: observability, Purview DLP, budgets and audit views.
- Test every persona and every negative case before go-live.
An RBAC model built for agents
Agents shouldn’t reuse broad analyst roles. I gave each data domain and task its own agent-facing role, with only the privileges the agent needs, and exposed only those roles as session:role:* scopes.
| Role (example) | Privileges |
|---|---|
SALES_WEST_AGENT_READ | Warehouse usage, database and schema usage, SELECT on the tables and semantic view, USAGE on the Cortex Agent, SNOWFLAKE.CORTEX_USER |
SALES_EAST_AGENT_READ | The same, filtered to another region by the row access policy |
<DOMAIN>_AGENT_RO (autonomous) | The same object privileges, granted only to the agent’s SERVICE_AGENT user |
Access follows Entra group membership through SCIM:
Entra group SF-Sales-West --SCIM--> Snowflake role "SF-SALES-WEST" (+ user, LOGIN_NAME = UPN)
Snowflake role "SF-SALES-WEST" inherits SALES_WEST_AGENT_READ
Token scope session:role:SALES_WEST_AGENT_READ selects that role for the OBO session
- SCIM uppercases role names, so reference them quoted (
"SF-SALES-WEST"). - Grant agent-facing roles to the SCIM roles, never directly to users.
- The agent can request every agent-facing scope. Snowflake keeps only the role the user’s groups grant and rejects the rest (
390186), so the agent needs no per-user role logic.
Agent-aware policies are the last layer. With IS_AGENTIC = TRUE on the integration and SERVICE_AGENT users, every agent session is flagged, so a masking policy can treat agents differently from people:
Show codeHide code
CASE
WHEN SYS_CONTEXT('SNOWFLAKE$CURRENT','IS_AGENT_ACTIVATED')::BOOLEAN = TRUE THEN '***agent-masked***'
WHEN CURRENT_ROLE() = 'ACCOUNTADMIN' THEN VAL
ELSE '***masked***'
ENDThe result: a West user and an East user asked the same agent the same question. Each saw only their own region, and both saw agent-masked emails. Cortex Analyst generated the same SQL for both. The difference came entirely from Snowflake policies on the OBO session, which is where data governance belongs.
Bringing it to Teams and Microsoft 365 Copilot
A custom engine agent built with the Microsoft 365 Agents SDK carries the OBO pattern into Teams and Copilot with no per-user code and, in the end, no secrets at all. On each message the agent gets the user’s SSO token and exchanges it on-behalf-of through the agent identity. It then calls the Cortex Agent and shows the user which Snowflake user and role answered.
A fully secretless bot. Three pieces replaced every client secret:
- Channel authentication uses the host’s managed identity as a federated credential on the bot app (
AUTHTYPE = FederatedCredentials). - The Azure Bot OAuth connection uses Aadv2 with Federated Credentials. A federated credential on the bot app, with the Bot Service token store as subject, replaces the connection’s secret. The subject must match the connection’s unique identifier exactly.
- The blueprint gets its token through the managed identity, as described above.
One app package serves both channels. The manifest’s bots entry puts the agent in Teams, and adding copilotAgents.customEngineAgents surfaces the same bot in Microsoft 365 Copilot.
Observability. The Microsoft OpenTelemetry distribution exports to Agent 365 over the service-to-service route. That route accepts only an app-only token for the agent identity, refreshed before it expires. User OBO tokens never go to telemetry. I wrapped each turn in an invoke-agent scope, the OBO and Snowflake step in an execute-tool scope, and the Cortex call in an inference scope.
Purview DLP. Before the Cortex Agent is called, the prompt goes to the Microsoft Graph processContent API. The Graph token comes from the same agent identity OBO exchange, with Content.Process.User granted on the agent identity, not the blueprint. The DLP policy uses the Applications location, scoped to the agent identity’s app ID, with a Restrict access: Block rule on prompts. In Teams, a message containing a test credit card number came back as “Your message was blocked by your organization’s data protection policy”, and Snowflake was never called.
Keep the gate fail-closed: if Purview can’t be reached, the turn is blocked. Responses can be audited but not blocked for this workload. DLP for AI apps is metered, so it needs pay-as-you-go billing and DSPM for AI. Judge success by a real block, not by the policy’s distribution status, which can show Pending for a live policy.
Turning it off, and proving what happened
Disabling the agent in Entra does not cut off Snowflake right away. Disabling the Snowflake user does. That was the most important result of my testing.
| Lever | New tokens | Token already held | Undo |
|---|---|---|---|
| Disable the agent identity in Entra | Refused within about a minute | Still accepted by Snowflake until it expires (about 60 minutes) | Re-enable: immediate |
| Disable the Snowflake user | Still issued by Entra | Rejected within seconds (390101) | Re-enable: seconds |
Snowflake validates tokens locally and doesn’t check revocation with Entra. For an emergency stop, pull both levers, keep access-token lifetimes short, and put the Snowflake user in your decommissioning runbook.
For audit, each side tells half the story:
- Snowflake: join
QUERY_HISTORY,SESSIONSandLOGIN_HISTORYon aQUERY_TAGthat the agent sets. You get the user, role, authentication method (OAUTH_ACCESS_TOKENorWORKLOAD_IDENTITY), client IP and status.ACCOUNT_USAGEviews can lag by up to about 3 hours. - Entra: the agent identity’s sign-in logs show autonomous calls as service-principal sign-ins, and OBO calls as non-interactive user sign-ins with the agent as the client.
- Together: correlate on the time window and the principal, with the
QUERY_TAGcarrying a run ID end to end.
One cost note. Identity checks cost almost nothing, but every Cortex Agent answer uses AI credits. A resource monitor on the warehouse doesn’t cover Cortex spend, and an account budget only alerts. A per-user Cortex quota on the agent is the built-in control that actually stops AI usage.
Ten lessons I’d pass on
- Inspect a real token before writing Snowflake configuration. A new Entra resource app issues v1 tokens (
sts.windows.netissuer), while Snowflake’s WIF app gets v2. The issuer must match exactly. - One value, four jobs. An agent identity’s app ID equals its object ID. That one value serves as
fmi_path, client ID, WIF subject andLOGIN_NAME. - Request the role explicitly. External OAuth starts the session in the user’s default role and fails (
390317) if that role isn’t in the token, so set the role on the connection or SQL API call. - One integration can serve both patterns. App-only tokens carry the role in
roles, notscp, and a mapping of('upn','sub')covers both OBO and autonomous agents. - Create every autonomous agent user as
SERVICE_AGENT. It is what makes WIF sessions show as agent sessions, so agent-aware policies apply on every path. - Grant to the agent identity, not the blueprint. Least privilege applies per agent.
- Put governance in Snowflake, not in prompts. The generated SQL is the same for every user; policies make the difference.
- Registry sync is inventory, identity is control. Use both, and record ownership in tags until synced agents can have owners.
- Telemetry and workload use different tokens. App-only for observability, OBO for data. Never mix them.
- Treat CLI output as sensitive. Agent 365 CLI output can include generated credentials, so move to federated credentials before production.
Before production, check this list: no client secrets anywhere; one trust path per agent; SCIM for people; agent-facing roles as the only scopes; network policies and Conditional Access for agent identities; DLP and audit dashboards; and tested runbooks for revocation and rotation.
Closing thoughts
The pieces now exist to run Snowflake Cortex Agents as first-class, governed agents in the Microsoft ecosystem: a real identity per agent, the user’s own permissions when it acts for them, mutual trust with no secrets in either direction, and a kill switch that actually works. Most of the effort goes into the decisions, not the code. Decide who the agent acts as, who owns the role decision, and which lever you’ll pull when something goes wrong.
Several building blocks are new or in preview: Agent 365, Entra Agent ID, Snowflake’s agent-aware features, outbound WIF, and DLP for AI apps through the Graph processContent API. Using Entra Agent ID tokens with Snowflake inbound WIF is behaviour I observed, not documented support. Expect details to change, and check each one against current documentation.
Disclaimer: This article reflects my own experience building a reference implementation in a test environment. It is provided for informational purposes only, as is, without warranty of any kind. It is not product documentation and does not change the support terms of any Microsoft or Snowflake product. Validate every configuration against current Microsoft Learn and Snowflake documentation, and with your account teams, before production use. Product names are trademarks of their respective owners.
¶ Discussion
Comments are powered by Giscus / GitHub Discussions. They appear here once configured — see
Configure Giscusin the project README and updateGISCUSinsrc/consts.ts.