You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建跨租户SharePoint数据源的Azure Cognitive Search索引器:连接失败

问题原因及解决方案

真实原因

  1. 委托权限不匹配服务级访问场景:Azure Cognitive Search索引器是后台无交互服务,你配置的Sites.Read.All和Files.Read.All属于委托权限(代表特定用户访问),这类权限依赖用户交互完成认证(如设备码流程),但索引器无法持久化用户会话,临时认证过期后必然出现连接失败。
  2. 跨租户访问缺少站点级权限授予:即使配置了应用权限,跨租户场景下还需在目标SharePoint站点中明确授予Entra应用的访问权限,否则应用无法读取站点内容。

解决方案

1. 替换为应用权限并重新获取管理员同意

  • 在目标租户的Entra ID应用注册中,删除原有委托权限Sites.Read.All和Files.Read.All,添加应用类型的Sites.Read.All权限(注意区分「应用权限」与「委托权限」)。
  • 重新申请该租户管理员完成权限同意操作。

2. 授予Entra应用访问目标SharePoint站点的权限

安装PnP PowerShell模块后,执行以下命令:

# 连接到目标SharePoint站点
Connect-PnPOnline -Url "https://<tenant_name>.sharepoint.com/sites/<site_name>" -Interactive

# 给Entra应用授予站点只读权限
Grant-PnPAzureADAppSitePermission -AppId "<application_id>" -DisplayName "Search Indexer App" -Permissions Read -Site "https://<tenant_name>.sharepoint.com/sites/<site_name>"

3. 验证数据源配置

确保数据源连接字符串参数正确,无需依赖用户交互认证:

{
    "name": "sharepoint-datasource",
    "type": "sharepoint",
    "credentials": {
        "connectionString": "SharePointOnlineEndpoint=https://<tenant_name>.sharepoint.com/sites/<site_name>;ApplicationId=<application_id>;TenantId=<tenant_id>"
    },
    "container": {
        "name": "defaultSiteLibrary",
        "query": null
    }
}

4. 重新部署索引器

删除原索引器后重新创建,或更新现有索引器配置,触发全量运行以测试连接有效性。


内容的提问来源于stack exchange,提问作者martinm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 22:41:16