面向 Microsoft Teams 和 Microsoft 365 Copilot 的 Cortex Agents

简介

对于大多数团队而言,要获取及时的数据见解,往往需要在专业分析平台和通信工具之间来回切换,从而导致延迟和生产力降低。将代理 AI 系统集成到 Microsoft Teams 可以直接为对话和决策提供答案,从而加速企业内部的信息流转。但是,构建既强大又直观的安全聊天分析解决方案是一项艰巨的任务。幸运的是,Snowflake 已经替您做好了这件事。

The Snowflake Cortex Agents integration for Microsoft Teams and Microsoft 365 Copilot embeds Snowflake's conversational AI agents into your business communication platform. Business teams and non-technical users can interact with their Snowflake structured and unstructured data using simple, natural language to receive direct answers and visualizations without leaving their Teams chats or the broader Microsoft 365 ecosystem. The integration is available via Microsoft AppSource (https://appsource.microsoft.com/en-us/product/Office365/WA200008996) for seamless deployment.

Use the following sections to set up the integration and start using it to get value from your data. For a Quickstart guide, see Getting Started with Cortex Agents for Microsoft Teams and Microsoft 365 Copilot (https://quickstarts.snowflake.com/guide/getting_started_with_the_microsoft_teams_and_365_copilot_cortex_app).

主要功能

  • Seamless analytics via natural language. Delight your business decision-makers by empowering them to get insights themselves within the Microsoft Teams and Microsoft 365 Copilot interfaces. You can discover trends and analyze data without technical expertise or waiting for a custom dashboard to be built. Users can ask questions conversationally and receive accurate, LLM-powered answers in text, tabular, or chart form on the fly, dramatically accelerating data-driven decision-making.

  • 双重界面覆盖完整工作流程。 面向 Microsoft Teams 的 Cortex Agents 提供两种不同的交互界面,以支持不同的业务需求。使用标准 Teams Application 在 Teams Bot 应用程序聊天中进行专门的深入分析,或者利用 Microsoft 365 Copilot Agent 将有针对性的 Snowflake 见解带入 Microsoft 365 Copilot 生态系统中更广泛的对话工作流程。

  • Powered by Snowflake Cortex Agents. This integration is powered by the Snowflake Cortex Agents API, which handles the complexities of generating accurate, reliable insights from your data. The agentic system intelligently interprets user requests and generates responses, saving your teams from having to build complex conversational AI patterns or manage underlying models. You can reuse the same agents you use with Snowflake Intelligence, avoiding duplicate configuration and governance effort.

  • 企业级安全与治理。 基于 Snowflake 的“隐私优先”基础,该集成确保您能够放心探索由 AI 驱动的各类用例。这意味着:

    • 您的数据始终处于 Snowflake 的治理范围内。 用户提示会发送到 Cortex Agents API,但为生成答案而查询的底层数据不会离开 Snowflake 的安全环境。生成的 SQL 查询将在您的 Snowflake 虚拟仓库中执行。

    • 与 Snowflake 的隐私和治理功能无缝集成。 该集成完全遵守 Snowflake 基于角色的访问控制 (RBAC)。代表用户执行的所有查询都遵循其既定权限,从而确保用户只能看到他们有权访问的数据。

设置集成

Cortex Agent 的 Microsoft Teams 集成允许组织管理员将多个 Snowflake 账户连接到其组织中的 Teams 和 Copilot 工作区。设置该集成只需几个简单的步骤,具体如下:

  1. Tenant-wide setup by Azure administrator. The integration requires a one-time setup by a Microsoft Azure administrator to grant consent for the Snowflake application within the Microsoft Entra ID (formerly Azure Active Directory) tenant. This step enables secure OAuth 2.0 authentication for the integration.

  2. Snowflake 安全集成。 Azure 管理员完成租户范围设置后,Snowflake 管理员必须为每个希望连接到 Microsoft Teams 或 M365 Copilot 应用的 Snowflake 账户配置安全集成。此步骤可确保集成可以安全地访问每个 Snowflake 账户中的必要数据。

  3. 将账户关联到机器人。 配置安全集成后,Snowflake 管理员就可以将 Snowflake 账户关联到 Microsoft Teams 或 M365 Copilot 机器人。此步骤允许机器人访问 Snowflake 账户的数据和功能,使用户能够直接在 Teams 或 Copilot 中与他们的数据进行交互。

先决条件

在开始集成过程之前,请确保已经具备以下条件:

  • 管理员访问权限。 设置需要同时具备 Snowflake 和 Microsoft 租户的管理访问权限。

  • Snowflake account region: Your Snowflake account must be hosted in the Azure East US 2 region. Snowflake intends to support more regions in the future.

  • Snowflake 管理权限: 您的 Snowflake 用户必须具有 ACCOUNTADMIN 或 SECURITYADMIN 角色的访问权限。这些权限是在 Snowflake 账户中创建必要的安全集成对象所必需的。

  • Microsoft 管理权限: 您的 Azure 用户必须拥有 Microsoft Entra ID 租户的全局管理员权限(或等效角色)。这些权限是为应用程序授予必要的租户范围管理员许可所必需的。

  • Microsoft 租户ID: 您需要准备好组织的 Microsoft 租户 ID 来配置 Snowflake 安全集成。有关查找组织租户 ID 的更多信息,请参阅 在 Azure 门户中获取订阅和租户 IDs (https://learn.microsoft.com/en-us/azure/azure-portal/get-subscription-tenant-id)。

  • 个人用户账户: 每个最终用户必须同时拥有自己的 Microsoft 用户账户和 Snowflake 用户账户。

  • 最终用户许可: 用户必须拥有相应的 Microsoft 许可证才能访问 Microsoft Teams。如果计划在 Microsoft 365 Copilot 中使用该集成,还需要 Copilot 许可证。

第 1 步:租户范围的 Entra ID 配置

要为 Cortex Agents 启用安全身份验证,Microsoft Azure 管理员必须同意托管在 Snowflake 租户中的两个应用程序,并为 Entra ID 租户中的每个应用程序创建 服务主体。这两个应用程序是:

  • Cortex Agents Bot OAuth Resource: 表示受保护的 Snowflake API,并定义客户端应用程序的访问权限(范围)。

  • Cortex Agents Bot Snowflake OAuth Client: 表示客户端应用程序,在本例中为 Teams 应用程序后端服务,它在请求访问令牌后调用 Snowflake API。

下面提供了对这些引用程序授予同意的说明。这两个应用程序的流程非常相似,但是具体的权限和范围略有不同。

确认权限授予

在对两个应用程序授予同意后,您可以通过查看 Microsoft Entra ID 门户的 Enterprise applications 部分来确认权限是否已成功授予。

  1. 如有必要,请登录到 Microsoft Entra 管理中心 (https://entra.microsoft.com/)。

  2. 在搜索框中输入“enterprise applications”导航到 Enterprise Applications,然后在结果中选择 Enterprise applications

  3. All applications 列表中,找到刚刚授予同意的两个应用程序:Snowflake Cortex Agents Bot OAuth Resource 和 Snowflake Cortex Agents Bot OAuth Client。一种简单的方法是搜索“Snowflake Cortex Agent”

    如果两个应用程序都出现在列表中,说明权限已正确授予。如果缺少一个或两个应用程序,请重新尝试授予同意。

第 2 步:Snowflake 安全集成

Integrating Snowflake with Microsoft Teams requires a security integration that establishes cryptographic trust between your Snowflake account and your Entra ID tenant. This process requires:

  • Enabling Entra ID as an external OAuth provider in Snowflake.

  • 为集成选择或创建至少一个 Cortex Agent 对象。

  • Granting required roles and privileges so intended users can invoke the agent.

启用 Entra ID 作为外部提供商 OAuth

Snowflake 安全集成对象表示与外部 OAuth 提供商(在本例中为 Microsoft Entra ID)的集成。此集成允许 Snowflake 对登录 Microsoft Teams 或 Copilot 的用户进行身份验证。

以下 SQL 语句是一个带注释的模板,用于创建此集成。此命令必须由具有 ACCOUNTADMIN 权限的角色执行。请将其中的 tenant-id 占位符替换为您的 Microsoft 租户 ID。

CREATE OR REPLACE SECURITY INTEGRATION entra_id_cortex_agents_integration
    TYPE = EXTERNAL_OAUTH
    ENABLED = TRUE
    EXTERNAL_OAUTH_TYPE = AZURE
    EXTERNAL_OAUTH_ISSUER = 'https://login.microsoftonline.com/<tenant-id>/v2.0'
    EXTERNAL_OAUTH_JWS_KEYS_URL = 'https://login.microsoftonline.com/<tenant-id>/discovery/v2.0/keys'
    EXTERNAL_OAUTH_AUDIENCE_LIST = ('5a840489-78db-4a42-8772-47be9d833efe')
    EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM = ('email', 'upn')
    EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE = 'email_address'
    EXTERNAL_OAUTH_ANY_ROLE_MODE = 'ENABLE'
Copy

有关此命令可用参数的完整参考,请参阅 CREATE SECURITY INTEGRATION (External OAuth)

EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM 和 EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE 参数共同将 Entra ID 身份与 Snowflake 身份关联起来。要使身份验证成功,JWT 中指定声明的值必须与 Snowflake 用户对象上指定属性的值完全匹配。Snowflake 推荐的两种主要配置是:

  • 按用户主体名称映射 (UPN):将 EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM 参数设置为 “upn”,并将 EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE 参数设置为“LOGIN_NAME”。

  • 按电子邮件地址映射:将 EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM 参数设置为“email”,并将 EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE 参数设置为“EMAIL_ADDRESS”。

上面的示例语句使用了电子邮件地址映射配置,但同时在 EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM 参数中指定了 UPN,允许您通过仅更改 EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE 来更改映射方法。

该示例语句还启用了 EXTERNAL_OAUTH_ANY_ROLE_MODE,因此会使用用户的默认角色。

有关 OAuth 范围的更多信息,请参阅 范围

用户预置要求

要确保使用前面描述的映射配置成功进行身份验证,请确保满足以下要求:

  • Entra ID 用户和 Snowflake 用户之间存在严格的一一对应关系。为每个将使用该集成的 Entra ID 用户指定或创建一个 Snowflake 用户。

  • 每个 Entra ID 用户仅映射到一个 Snowflake 用户。对于电子邮件映射,Entra ID 主电子邮件必须与 Snowflake 用户的 EMAIL_ADDRESS 完全匹配。对于 UPN 映射,Entra ID UPN 必须与 Snowflake 用户的 LOGIN_NAME 完全匹配。

为减少手动管理工作量,您可选择配置从 Entra ID 到 Snowflake 的自动用户预置和取消预置。请参阅 配置自动预置 (https://learn.microsoft.com/en-us/entra/identity/saas-apps/snowflake-provisioning-tutorial)。

Create and configure the Cortex Agents

创建安全集成后,请确保至少有一个 Cortex Agent 对象 存在于您的 Snowflake 账户中,供 Teams 或 Microsoft 365 Copilot 集成使用。

若您已有可正常使用的代理,则此步骤无需采取进一步操作。

要创建新代理,请按照 说明

备注

如果您已是 Snowflake Intelligence 的用户,并为此创建了代理,则可将这些代理重复用于与 Microsoft Teams 和 Microsoft 365 Copilot 集成。您无需重新创建或重新配置;您对代理所做的任何更改(例如指令、工具、底层对象或权限),均会立即同步呈现于所有三个界面之中。

Grant required privileges to users

请确保集成运行的角色(每个用户的默认角色或允许的次要角色)具备 访问控制要求部分 所述的授权。

第 3 步:设置 Teams 应用程序并连接 Snowflake 账户

集成过程的最后一步,是设置 Microsoft Teams 应用程序并将其与将要使用的 Snowflake 用户连接。这一步需要完成以下任务:

  • 从 Teams 商店安装 Cortex Agents 应用程序

  • 将您的 Snowflake 账户连接到 Teams 应用程序

从 Teams 商店安装应用程序

所有用户都必须从 Microsoft Teams 商店安装 Cortex Agents 应用程序。要安装该应用程序,请在 Teams 应用商店中搜索 “Snowflake Cortex Agents”,然后点击 Add 即可安装该应用程序。

备注

根据贵组织的 Microsoft Teams 政策,Teams 管理员可能需要批准该应用程序才能提供给用户。有关说明,请参阅 Teams 管理中心中的应用程序管理和治理概述 (https://learn.microsoft.com/en-us/microsoftteams/manage-apps)。

将 Snowflake 账户连接到 Teams 应用程序

系统会提示在 Teams 中与 Cortex Agents 应用程序进行交互的第一个用户将其 Snowflake 账户连接到该应用程序。此用户必须在 Snowflake 中拥有 ACCOUNTADMIN 或 SECURITYADMIN 角色才能成功完成此步骤。

To recap, every user's default role in Snowflake must have the required privileges to access the agent's objects, as described in the access control requirements section of the Cortex Agents topic.

默认情况下,安全集成会阻止 Snowflake 的主要管理角色。因此,像 ACCOUNTADMIN 这样的管理角色,不能作为设置 Teams Bot 用户的默认角色。有关此限制的信息,请参阅 CREATE SECURITY INTEGRATION 主题中的 BLOCKED_ROLES_LIST

Snowflake recommends you create a dedicated, non-administrative role with the required permissions and set it as the default for the setup user. Alternatively, use the SECONDARY ROLES mechanism to grant the additional permissions without altering the user's primary default role, as follows:

GRANT ROLE <integration_specific_role> TO USER <user_name>;
ALTER USER <user_name> SET DEFAULT_SECONDARY_ROLES = ('ALL');
Copy

要设置 Teams Bot,请按照以下步骤操作:

  1. 在提示“管理员需要为 Teams 激励功能配置 Snowflake”的通知下方,点击 I'm the Snowflake administrator 开始配置流程。

  2. Provide your Snowflake account URL where indicated, and select Connect Snowflake account.

    To find your account URL, log in to Snowsight and click the account selector in the bottom left corner of the page. The hostname portion of the URL is displayed at the top of the menu and is in the format your-organization-your-account. The full URL is your-organization-your-account.snowflakecomputing.cn.

    配置向导会验证 URL 是否指向 Azure US 东部 2 区域的有效 Snowflake 实例,并确认您的用户是否有访问权限,以及是否具有所需的管理权限。

After the setup passes final validation, the Teams app is connected to your Snowflake account and the agents are ready to use.

小技巧

After you have connected your Snowflake account to the Cortex Teams app, you can connect additional Snowflake accounts to the same app by logging into the Teams app with a user that has the necessary privileges and issuing the "add new account" command in the chat.

Using the Cortex Agents

After the integration is set up, the bot appears in the Microsoft Teams interface, allowing your users to interact with it in a private chat. Users can ask questions in natural language, and the bot responds with answers based on Snowflake data.

In Microsoft 365 Copilot, your users can interact with the agents in the context of their broader workflows, asking questions and receiving answers about their Snowflake data within the Copilot interface.

对答案的反馈(仅限 Teams)

用户可以直接在 Microsoft Teams 界面中提供有关代理响应的定性反馈(例如,将答案标记为有帮助或无帮助,并可选择添加注释)。用户还可以查看他们之前提交的反馈。有关说明,请参阅 View user feedback for agents

备注

反馈功能仅在 Microsoft Teams 中可用,在 Microsoft 365 Copilot 体验中不受支持。

在账户和代理之间切换

您可以将多个 Snowflake 账户连接到集成。每个连接的账户都可以公开一个或多个 Cortex Agent。连接账户后,用户只需单击即可在 Teams UI 中切换账户和代理;无需重新身份验证或重新输入连接详细信息。在账户和代理之间切换可以更轻松地比较跨业务领域(例如,销售与营销)的见解,同时保留每个用户的安全上下文。

小技巧

如果您更喜欢通过命令而非 UI 进行操作,也可以在同一账户中通过对话方式在不同的代理之间切换(例如输入 “choose agent”)。

安全注意事项

Snowflake 为 Microsoft Teams 提供的 Cortex Agents 集成在设计上充分考虑了安全性,结合了 Snowflake 现有的安全功能以及 Microsoft Entra ID 的身份验证能力。该集成可确保用户数据的安全,同时通过 Snowflake 基于角色的访问控制 (RBAC) 系统控制访问权限。

端到端身份验证流程

要了解在 Microsoft Teams 中使用 Cortex Agents 集成的安全性影响,了解端到端身份验证流程非常重要。此过程涉及以下步骤:

  • 用户交互: 用户在 Microsoft Teams 中向 Snowflake Cortex Agents 机器人发送消息。

  • 身份验证触发: 机器人的后端服务(“客户端”应用程序)启动 OAuth 2.0 流程,将用户重定向到 Microsoft Entra ID。

  • 用户身份验证: 用户使用公司凭据登录其 Microsoft 账户,满足租户强制执行的任何 MFA 或条件访问策略。

  • 令牌签发: Entra ID 提供短期授权码。该机器人的后端安全地将此代码交换为 JWT 访问令牌。

  • 对 Snowflake 的 API 调用: 机器人后端调用 Snowflake Cortex Agents API,并在 Authorization: Bearer 标头中包含该访问令牌。

  • Snowflake 令牌验证: Snowflake 服务接收请求,并根据在 Snowflake 安全集成对象中定义的策略验证 JWT。

基于角色的访问控制

由于 Teams 集成在特定用户角色下使用 Cortex Agents API,因此所有 Cortex Agents 请求都会严格在用户 Snowflake 指定角色的权限范围内执行。该代理会继承现有的所有数据治理控制,包括:

  • 基于角色的访问控制: 代理只能访问用户角色允许的数据库、架构、表和仓库。

  • 动态数据掩码策略: 代理遵守动态数据掩码策略,仅在用户角色允许时才授予访问权限。

  • 行级访问策略: 代理强制执行行级安全策略。

该代理无法绕过任何现有的 Snowflake 安全控制,用户也无法访问其未获授权查看的数据。

当前限制

OAuth 身份提供商必须是 Entra ID

The integration exclusively supports Microsoft Entra ID as the identity provider for authentication and requires a direct one-to-one mapping between Entra ID users and Snowflake users. Organizations that use another primary IdP (for example, Okta or another SAML/OIDC provider) can enable this integration by configuring standard identity federation between that provider and Microsoft Entra ID. In this federated model, the primary IdP handles the user's sign-in, after which Entra ID issues the final token required by the integration.

依赖默认用户角色

由于 Cortex Agents API 中的架构限制,集成的功能与每个用户的默认 Snowflake 角色相关联,Cortex Agents 根据身份验证期间建立的角色上下文来确定会话权限。因此,必须向用户的默认角色授予底层对象的所有必要权限,才能使代理正常运行。虽然 Snowflake 的 SECONDARY ROLES 功能可以帮助扩大数据访问权限,但主要执行上下文仍由用户的默认角色治理。

故障排除

If you encounter issues with the Cortex Agents integration for Microsoft Teams, check the folliwng sections for possible solutions.

权限和访问权限问题

用户的默认角色必须具有访问代理使用或访问的对象所需的权限。由于访问问题导致的错误消息通常包含“database object does not exist or not authorized”。

Troubleshooting such issues involves checking that user's default role is set to a role that has the required privileges.

默认角色设置

The first step in troubleshooting access issues is to check the user's default role setting. To verify this setting, use the DESCRIBE USER command. Check the DEFAULT_ROLE property in the output. If the user's default role is incorrect, change it using the ALTER USER command.

ALTER USER <user_name> SET DEFAULT_ROLE = '<correct_role>';
Copy

如果更改用户的主要 DEFAULT_ROLE 角色不可行,则可以使用 Snowflake 的次要角色机制。用户可以使用其主要角色和活动次要角色的组合权限执行操作。这允许为用户额外授予集成专用的角色,而不必更改主要角色。

要为 Cortex Agents 集成添加次要角色,请使用如下 SQL 命令。

GRANT ROLE <integration_specific_role> TO USER <user_name>;
ALTER USER <user_name> SET DEFAULT_SECONDARY_ROLES = ('ALL');
Copy

所需权限

请确保集成运行的角色(每个用户的默认角色或允许的次要角色)具备 访问控制要求部分 所述的授权。

安全集成问题

Snowflake 安全集成将 Microsoft Entra ID 租户连接到 Snowflake 账户。本节中的问题与安全集成有关。

OAuth 访问令牌无效(错误代码 390303)

此错误可能表示安全集成中的一个或多个属性值不正确,从而导致 Snowflake 无法验证从 Entra ID 收到的访问令牌。要纠正此问题,请检查安全集成中的以下字段。特别是,请确保租户 ID 在 URLs 中是正确的。

  • EXTERNAL_OAUTH_ISSUER: This must be set to the correct Entra ID issuer URL, which is in the format https://login.microsoftonline.com/tenant-id/v2.0, where tenant-id is your organization's Microsoft tenant ID.

  • EXTERNAL_OAUTH_JWS_KEYS_URL: This must be set to the correct JWS keys URL, which is in the format https://login.microsoftonline.com/tenant-id/discovery/v2.0/keys, where tenant-id is your organization's Microsoft tenant ID.

  • EXTERNAL_OAUTH_AUDIENCE_LIST: 这必须包括 Cortex Agents Bot OAuth Resource 应用程序(即应用程序 ID 5a840489-78db-4a42-8772-47be9d833efe)的正确受众。

使用 ALTER SECURITY INTEGRATION 命令更新任何不正确的值。

用户名或密码不正确(错误代码 390304)

This error message points to a mismatch between the user identifier sent by Entra ID and the corresponding user's record in Snowflake, usually because the Entra ID user identity does not map to exactly one Snowflake user. This can happen when the Snowflake user does not exist, when the mapped UPN or email address is incorrect, or when the mapping resolves to multiple Snowflake users (for example, if the mapping is performed using email address and multiple users share the same address).

The error message includes the UPN and email of the user attempting to log in. Use this information to verify the affected user's configuration using the DESCRIBE USER command. Make sure the user's NAME or EMAIL property matches the value of the same property in Entra ID for the corresponding user. When using email address mapping, each user in the Snowflake account that will use the integration must have a unique email address.

角色未在访问令牌中列出或已被过滤掉(错误代码 390317)

当 Snowflake 无法根据 OAuth 访问令牌中的信息向用户分配角色时,就会发生此错误。访问令牌使用 session:role-any 范围进行配置,允许用户代入 Snowflake 中的任何分配角色。但是,必须明确配置安全集成才能允许这种行为。

使用 DESCRIBE SECURITY INTEGRATION 命令检查 EXTERNAL_OAUTH_ANY_ROLE_MODE 属性的值,然后将其更改为 ENABLEENABLE_FOR_LOGIN

DESCRIBE SECURITY INTEGRATION entra_id_cortex_agents_integration;

ALTER SECURITY INTEGRATION entra_id_cortex_agents_integration
    SET EXTERNAL_OAUTH_ANY_ROLE_MODE = 'ENABLE';
Copy

未向此用户授予连接字符串中指定的角色(错误代码 390186)

当 Snowflake 安全集成不允许用户的默认角色使用安全集成时,就会出现此错误。

要解决此问题,请检查 DESCRIBE SECURITY INTEGRATION 输出中的以下属性:

  • EXTERNAL_OAUTH_ALLOWED_ROLES_LIST:如果已启用该参数,请验证它是否包含用户的默认角色。

  • EXTERNAL_OAUTH_BLOCKED_ROLES_LIST:如果已启用该参数,请验证它是否不包含用户的默认角色。

语言: 中文