Trying Out User-Delegated Authentication with the Snowflake Connector from Microsoft Copilot Studio

Trying Out User-Delegated Authentication with the Snowflake Connector from Microsoft Copilot Studio

I tried a setup in which Copilot Studio uses the Snowflake connector with user-delegated authentication to query Snowflake data as each individual user.
2026.11.29

This page has been translated by machine translation. View original

Introduction

This article covers my experiment with a setup in which an agent created in Microsoft Copilot Studio queries Snowflake data through the Power Platform Snowflake connector, using user-delegated authentication (a method in which each user connects as their own Snowflake user).

Copilot Studio

Copilot Studio is a low-code platform provided by Microsoft for creating and publishing agents.

https://learn.microsoft.com/en-us/microsoft-copilot-studio/fundamentals-what-is-copilot-studio

The flow from creating an agent to using it is as follows.

Stage Description
Create Write instructions, and add tools (such as connector actions) and knowledge
Test The author verifies the behavior in the test panel on the Copilot Studio screen
Publish Publish to channels such as Teams, Microsoft 365 Copilot, and websites
Use Users talk to the agent from the chat in the publishing destination

As tools to add to an agent, you can use the actions of Power Platform connectors. The Snowflake connector is one of them.

Snowflake connector actions

On the screen for adding tools to a Copilot Studio agent, three Snowflake tools are displayed. These are the actions of the Power Platform Snowflake connector.

https://learn.microsoft.com/en-us/connectors/snowflakev2/

Action Role
Submit SQL Statement for Execution Sends SQL and executes it. You can specify the database, schema, warehouse, role, and so on
Check the Status and Get Results Passes the ID assigned to each execution (statementHandle) to check the execution status and retrieve results
Cancel the Execution of a Statement Cancels SQL that is running

A characteristic is that the agent builds and executes SQL directly, so it does not go through Cortex Agents or semantic views. Also, since arbitrary SQL can be executed, I think it is safest to make the connection role a read-only, least-privilege role.

Types of authentication

There are two types of authentication for connecting the connector.

Authentication type Behavior Connection input items
Service principal Delegated Auth Executes with the user's own permissions Client ID, Client Secret, Resource URL
Service principal (Microsoft Entra ID application) Executes with a shared service principal connection Tenant, Client ID, Client Secret, Resource URL, Snowflake URL, database, warehouse, role, schema

In this article, I try user delegation (Service principal Delegated Auth), in which each user can connect as their own Snowflake user.

Resource app and client app

To connect, we create the following apps in Entra ID in order to combine Entra ID with Snowflake's External OAuth.

App Role
Resource app Represents the destination of the token (audience)
Client app The identity of the side that obtains and uses the token
  • The Application ID URI of the resource app (api://<ID>) becomes the destination of the token. It is set in the EXTERNAL_OAUTH_AUDIENCE_LIST of the Snowflake integration, and only matching tokens are accepted
  • The scope of the resource app (session:scope:<role name>) indicates which Snowflake role to use
  • The Client ID and Client Secret of the client app are the values to enter in the connector's connection

https://docs.snowflake.com/en/user-guide/oauth-azure

Prerequisites

Verification environment

The following environment was used.

  • Snowflake: Trial account (AWS Tokyo region)
  • Microsoft 365 / Microsoft Entra ID: A verification tenant prepared with a Microsoft 365 Business Standard trial (worked as Global Administrator)
  • Copilot Studio: Trial version
  • Power Platform: An environment with Dataverse enabled

Preparation

Creating an environment with Dataverse enabled

To create an agent in Copilot Studio, the environment needs Dataverse. In an environment where Dataverse was not set up, the following message was displayed when creating an agent.

Dataverse is not set up in this environment
Agents require Microsoft Dataverse to save their configuration, but it is not set up in this environment. Ask your administrator to provision Dataverse for this environment and try again.

First, in the Power Platform admin center, add Dataverse to the tenant from "Manage > Environments > Add Dataverse".

After creation, the environment is displayed as shown below.

Setting up pay-as-you-go

In a trial tenant, the environment has no Copilot Studio credits. When I ran the agent in this state, the following error occurred.

You need credits to continue. Credits power building and running your agents and workflows. This environment is out of credits. Contact your admin to add more credits. Error code: EnforcementUsageCredits

You can create the agent and create the tool connection, but it stops at the stage of running a question.
This time, I set up pay-as-you-go in the admin center, activated the spending policy, and verified the behavior.

Pay-as-you-go charges only for what you use. Since costs are incurred according to the scale of the verification, I think it is a good idea to check the spending limit settings.

Snowflake: sample data and role

I created sample data for verification and a read-only role with the following content.

CREATE DATABASE IF NOT EXISTS copilot_lab;
CREATE SCHEMA IF NOT EXISTS copilot_lab.sales;

CREATE OR REPLACE TABLE copilot_lab.sales.daily_sales AS
SELECT d.sale_date, c.product_category, r.region,
       UNIFORM(50000, 150000, RANDOM()) AS sales_amount,
       UNIFORM(10, 80, RANDOM()) AS quantity
FROM (SELECT DATEADD(day, SEQ4(), '2026-09-30'::DATE) AS sale_date
      FROM TABLE(GENERATOR(ROWCOUNT => 7))) d,
     (SELECT column1 AS product_category
      FROM VALUES ('Electronics'), ('Apparel'), ('Food')) c,
     (SELECT column1 AS region
      FROM VALUES ('Tokyo'), ('Osaka'), ('Nagoya')) r;

CREATE ROLE IF NOT EXISTS copilot_readonly;
GRANT USAGE ON WAREHOUSE COMPUTE_WH TO ROLE copilot_readonly;
GRANT USAGE ON DATABASE copilot_lab TO ROLE copilot_readonly;
GRANT USAGE ON SCHEMA copilot_lab.sales TO ROLE copilot_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA copilot_lab.sales TO ROLE copilot_readonly;

-- Grant the role to the connecting user
GRANT ROLE copilot_readonly TO USER <Snowflake のユーザー名>;

The copilot_readonly role must be granted to the connecting user.

Entra ID side: creating the apps

In the Entra admin center (https://entra.microsoft.com), create the resource app and the client app in the GUI.

Resource app

In the Entra admin center, select "App registrations > New registration".

The name is arbitrary, but here I used "Snowflake OAuth Resource".

After registering the app, in "Expose an API" of the target app, click "Add" for the Application ID URI.

The screen below is displayed, so save with the default api://<application ID> as is.

Next, in the same app, click "Add a scope" and enter the values as shown below in the menu that appears.

Item Value entered
Scope name session:scope:copilot_readonly
Who can consent Admins and users
Admin consent display name Snowflake COPILOT_READONLY ロールでの利用
Admin consent description Snowflake の COPILOT_READONLY ロールで、サインインしたユーザーとして接続することを許可します
User consent display name (optional) Snowflake COPILOT_READONLY ロールでの利用
User consent description (optional) Snowflake の COPILOT_READONLY ロールで、あなたとして接続することを許可します
State Enabled

The scope name is a value that tells Snowflake which role to use, and its format is session:scope:<role name>. What follows session:scope: should match the Snowflake role name. The wording displayed on the consent screen (display name and description) does not affect the behavior.

https://docs.snowflake.com/en/user-guide/oauth-azure#configure-the-oauth-resource-in-microsoft-entra-id

Next, check requestedAccessTokenVersion in "Manifest".

"api": {
    "requestedAccessTokenVersion": null,

If this value is null or 1, the token's issuer is https://sts.windows.net/<tenant ID>/. If it is 2, the issuer changes, so the Snowflake-side settings also change. In this case it was null.

Client app

Next, register the client app. In the Entra admin center, select "App registrations > New registration" again.
The name is arbitrary, so I used Snowflake OAuth Client; for the redirect URI, set the platform to "Web" and enter https://global.consent.azure-apim.net/redirect/snowflakev2.

This redirect URI is a fixed value and is described in the user delegation steps of the Snowflake connector documentation.

After registration, add a "New client secret" in "Certificates & secrets".
Make a note of the secret value, as it will be used later.

Next, in "API permissions", go to "Add a permission > APIs my organization uses" tab, search for the app name Snowflake OAuth Resource or its application ID, and add it.

After adding it, click "Grant admin consent for <tenant name>" shown below, and confirm that the status becomes "Granted".

Consent screen:

Consent result:

Up to this point, make a note of the following values to use in the following steps.

Value Source
Tenant ID "Overview" in the Entra admin center
Application ID URI of the resource app "Expose an API" of the resource app (api://<ID>. Does not include the scope part)
Client ID of the client app "Application (client) ID" in the "Overview" of the client app
Client Secret The "Value" in "Certificates & secrets" of the client app (not the secret ID)

Snowflake side: creating the External OAuth integration

Create an External OAuth integration that performs token validation and user mapping.

USE ROLE ACCOUNTADMIN;

CREATE OR REPLACE SECURITY INTEGRATION copilot_studio_external_oauth
  TYPE = EXTERNAL_OAUTH
  ENABLED = TRUE
  EXTERNAL_OAUTH_TYPE = AZURE
  EXTERNAL_OAUTH_ISSUER = 'https://sts.windows.net/<テナント ID>/'
  EXTERNAL_OAUTH_JWS_KEYS_URL = 'https://login.microsoftonline.com/<テナント ID>/discovery/v2.0/keys'
  EXTERNAL_OAUTH_AUDIENCE_LIST = ('api://<リソースアプリのアプリケーション ID>')
  EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM = 'upn'
  EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE = 'email_address'
  EXTERNAL_OAUTH_ANY_ROLE_MODE = 'ENABLE';

DESCRIBE SECURITY INTEGRATION copilot_studio_external_oauth;
  • The trailing / of the issuer must exactly match the value in the token
  • For EXTERNAL_OAUTH_AUDIENCE_LIST, specify up to api://<ID> of the Application ID URI. Do not include /session:scope:...
  • This time, since the Entra ID UPN and the email address were the same value, the token's upn is mapped to the Snowflake user's EMAIL_ADDRESS. To map to LOGIN_NAME, set EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE to 'login_name'
  • The role is determined by the token's scope (session:scope:copilot_readonly). With DESCRIBE, confirm that the role you use is not included in the list of blocked roles (ACCOUNTADMIN, ORGADMIN, SECURITYADMIN)

Copilot Studio: adding tools and connecting

Adding tools

In the "Tools" of the Copilot Studio agent, use "Add a tool" to add the three actions of the Snowflake connector.

Creating the connection

Create the connection from the tool details.

On the connection creation screen, switch "Authentication type" to Service principal Delegated Auth, then enter the following values.

Item Value
Client ID Client ID of the client app
Client Secret Secret value of the client app
Resource URL Application ID URI of the resource app (api://<ID>)

When connecting, the Entra ID sign-in and consent screens are displayed. The UPN of the signed-in user is mapped to the Snowflake user's EMAIL.
If there are no problems, the display is as shown below.

Setting optional parameters

In a user-delegated connection, the warehouse, role, database, and schema are specified not in the connection but in the tool's optional parameters.
Here I set the following.

Input Value
Warehouse COMPUTE_WH
Role COPILOT_READONLY
Database COPILOT_LAB
Schema SALES

There is also a SQL (Statement) field, but if you specify it, the tool is fixed to that SQL. If you don't specify it, the agent builds SQL from the question and instructions.

Verifying operation

Errors during connection and how to handle them

I encountered the following errors before actually connecting. I hope they are helpful if you try the same configuration.

Error Cause Solution
AADSTS650057: Invalid resource The Client ID entered in the connection belonged to a different app, not the one created this time In "Overview" under app registrations, check the name of the app created this time and enter that application (client) ID
This tool is temporarily unavailable ... Service availability · 5xx Optional parameters such as the warehouse were not specified Run with the optional parameters explicitly specified
EnforcementUsageCredits The environment had no Copilot Studio credits Set up pay-as-you-go

In the 5xx error, Snowflake's LOGIN_HISTORY recorded the OAuth login as successful, but QUERY_HISTORY did not record any SQL. It is thought that authentication succeeded and it stopped before the SQL was executed.

Running from the agent

I entered questions in the test panel to verify. I asked twice, changing the tool's optional parameter settings.
*I forgot to take screenshots of the answers, so I have included text copies of the answers.

When SQL is fixed

I asked a question with the following SQL specified and fixed in the Statement of Submit SQL Statement for Execution.

SELECT region, SUM(sales_amount) AS total FROM copilot_lab.sales.daily_sales GROUP BY region ORDER BY total DESC

Question:

使用可能なテーブルを教えて

Answer (excerpt):

The only table available is COPILOT_LAB.SALES.DAILY_SALES. The query that can be executed on this connection is fixed to a single predetermined query that aggregates this table.

Item Content
Database COPILOT_LAB
Schema SALES
Table DAILY_SALES
Role COPILOT_READONLY (read-only)
Warehouse COMPUTE_WH
Executable query SELECT region, SUM(sales_amount) AS total FROM copilot_lab.sales.daily_sales GROUP BY region ORDER BY total DESC

I executed this query and confirmed that the table can be accessed. The results are as follows.

Region Total sales
Osaka 2,390,533
Tokyo 1,977,096
Nagoya 1,885,731

When SQL is fixed, only the one specified SQL can be executed. Regardless of the content of the question, that SQL was executed.

When SQL is not fixed

I removed the Statement specification, leaving the agent to build SQL according to the question, and asked a question.

Question:

全体の売上金額の合計を教えてください

Answer:

The total sales amount is 6,253,360. I summed all 63 rows of COPILOT_LAB.SALES.DAILY_SALES.

Item Value
Total sales amount 6,253,360
Number of rows 63
Period 2026-09-30 to 2026-10-06

This value also matches the sum of the previous regional totals (Osaka 2,390,533, Tokyo 1,977,096, Nagoya 1,885,731).

I previously told you that "only one fixed query can be executed on this connection," but that was incorrect. I had overlooked another connection that can execute SQL freely, and this aggregation was also executed there. For this reason, it may also be possible to get a list of tables with SHOW TABLES.

Conclusion

Using the Snowflake connector from Copilot Studio, I confirmed that SQL can be executed with user delegation as each user's own Snowflake user.
I hope this content is helpful to someone.


Snowflakeの導入支援はクラスメソッドに!

クラスメソッドでは Snowflake の導入を支援しております。
製品の詳細や支援の内容についてお気軽にお問い合わせください。

Snowflakeの詳細を見る

Share this article