Microsoft Graph 连接器的模拟 Teams 管理中心通知
Microsoft Graph 连接器允许将组织内容引入 Microsoft 365。 无论存储在何处,都可以使用 Microsoft Graph 连接器从一个位置查找内容。 更重要的是,它提供 Microsoft Copilot Microsoft 365 访问内容,以便它可以帮助你获取更相关的答案。
在组织中部署 Graph 连接器时,应考虑将它们打包为 Microsoft Teams 应用。 这样,他们就会部署到 Teams 管理中心,管理员可以从中以熟悉的方式控制他们。 若要将 Graph 连接器打包为 Teams 应用,需要使用从 Teams 管理中心接收 Webhook 的 API 进行扩展。
开发人员代理允许你测试 Microsoft Graph 连接器如何处理 Teams 管理中心的通知。 可以模拟用于启用和禁用 Graph 连接器的通知,并检查连接器是否正确处理它。 使用开发代理,可以验证如何端到端配置连接器:从验证令牌到运行初始内容引入。 开发代理允许在本地测试连接器,而无需将其部署到 Teams 管理中心。
开始之前
开始模拟 Teams 管理中心通知之前,请完成以下步骤。
下载适用于 Microsoft Graph 连接器开发代理预设的 Teams 管理中心通知
首先,下载用于模拟 Microsoft Graph 连接器的 Teams 管理中心通知的开发代理预设。 在命令提示符下,运行以下命令:
devproxy preset get microsoft-graph-connector-notification
开发代理下载预设并将其保存在 开发代理安装目录中的预设 文件夹中。
配置预设以将通知发送到 API
在代码编辑器中 ~appFolder/presets/microsoft-graph-connector-notification/graph-connector-notification-enabled.json
,打开该文件,其中 ~appFolder
引用了开发代理安装文件夹。 使用 request.url
从 Teams 管理中心接收通知的 API 的 URL 更新属性。
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.24.0/mockrequestplugin.schema.json",
"request": {
"url": "http://localhost:3000/api/notification",
"method": "POST",
// [...] trimmed for brevity
}
}
按照文件相同的步骤操作 graph-connector-notification-disabled.json
。
为 Microsoft Graph 连接器配置租户 ID 和 Entra 应用
开发代理模拟验证 Teams 管理中心通知中的令牌,并为连接器的 Microsoft Graph 颁发访问令牌。 开发代理使用模拟Microsoft 365 租户 ID 和 Entra 应用。 若要截获来自 Graph 连接器的请求,请将租户 ID 更新为fa15d692-e9c7-4460-a743-29f29522229
和 Entra 应用 ID。00001111-aaaa-2222-bbbb-3333cccc4444
如果要使用自己的 ID,请更新所有预设文件中的值。
模拟 Teams 管理中心通知以启用 Microsoft Graph 连接器
启动从 Teams 管理中心接收通知的 API。 确保它通过开发代理代理其请求。
接下来,在命令提示符下,使用用于模拟 Teams 管理中心通知来启用 Microsoft Graph 连接器的预设启动开发代理。
devproxy --config-file "~appFolder/presets/microsoft-graph-connector-notification/devproxyrc.json"
开发代理启动后,按 w 从 Teams 管理中心模拟 Webhook,以便启用 Microsoft Graph 连接器。 开发人员代理将通知发送到 API,该通知应像来自 Teams 管理中心一样对其进行处理。
准备就绪后,若要停止开发代理,请按 Ctrl+c。
模拟用于禁用 Microsoft Graph 连接器的 Teams 管理中心通知
在代码编辑器中 ~appFolder/presets/microsoft-graph-connector-notification/devproxyrc.json
,打开该文件,其中 ~appFolder
引用了开发代理安装文件夹。 找到已启用通知的 GraphConnectorNotificationPlugin
实例,并将 enabled
属性更改为 false
。 找到已禁用通知的 GraphConnectorNotificationPlugin
实例,并将 enabled
属性更改为 true
。 配置文件应类似于:
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.24.0/rc.schema.json",
"plugins": [
{
"name": "GraphConnectorGuidancePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll"
},
{
"name": "GraphConnectorNotificationPlugin",
"enabled": false,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "graphConnectorNotificationEnabled"
},
{
"name": "GraphConnectorNotificationPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "graphConnectorNotificationDisabled"
},
// [...] trimmed for brevity
]
// [...] trimmed for brevity
}
保存所做更改。
测试启用 Microsoft Graph 连接器的通知时,请遵循前面所述的相同步骤。
准备就绪后,若要停止开发代理,请按 Ctrl+c。
下一步
详细了解 GraphConnectorNotificationPlugin。