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

遵循Azure向量搜索REST指南时遭遇HTTP 403禁止错误

Azure AI Search 创建索引时 HTTP 403 错误排查方案

排除代理、防火墙因素后,针对你执行索引创建请求时出现的403禁止访问问题,可按以下方向逐一排查:

  • 确认身份令牌权限
    你使用的个人身份令牌(Bearer Token)对应的Azure AD账户,必须拥有Azure AI Search服务的参与者或所有者权限。若采用RBAC权限模型,需确保账户被分配搜索服务参与者这类具备写入权限的角色,仅读者权限无法创建索引。

  • 验证令牌有效性
    Azure AD令牌默认有效期仅1小时左右,若生成时间过久需重新获取新令牌替换@token的值。另外可通过JWT解码工具查看令牌内容,确认受众(aud)是否正确指向Azure AI Search服务。

  • 核对服务URL格式
    @baseUrl必须为https://<你的搜索服务名称>.search.windows.net格式,末尾不要添加斜杠,避免URL拼接错误导致权限验证失败。

  • 检查API版本兼容性
    确认你的Azure AI Search服务实例支持2023-11-01这个API版本,若为较旧实例,可尝试使用兼容的预览版(如2023-07-01-Preview),但优先推荐匹配官方指南的版本。

  • 补充确认IP防火墙设置
    再次确认Azure AI Search服务的防火墙白名单中,已添加发起请求的当前IP地址,即使之前排查过也可能存在配置遗漏。

  • 修正请求格式错误
    你的请求存在格式问题:

    • 请求头Content-Type和Authorization需与HTTP/1.1左对齐,不能有多余缩进;
    • 原代码中@token的占位符末尾少写一个字母E(PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HER),实际替换时需避免拼写错误。

以下是修正格式后的完整请求示例(替换占位符后即可使用):

@baseUrl = https://<你的搜索服务名称>.search.windows.net
@token = <你的有效身份令牌>

### Create a new index
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{token}}

{
    "name": "hotels-vector-quickstart",
    "fields": [
        {
            "name": "HotelId", 
            "type": "Edm.String",
            "searchable": false, 
            "filterable": true, 
            "retrievable": true, 
            "sortable": false, 
            "facetable": false,
            "key": true
        },
        {
            "name": "HotelName", 
            "type": "Edm.String",
            "searchable": true, 
            "filterable": false, 
            "retrievable": true, 
            "sortable": true, 
            "facetable": false
        },
        {
            "name": "HotelNameVector",
            "type": "Collection(Edm.Single)",
            "searchable": true,
            "retrievable": true,
            "dimensions": 1536,
            "vectorSearchProfile": "my-vector-profile"
        },
        {
            "name": "Description", 
            "type": "Edm.String",
            "searchable": true, 
            "filterable": false, 
            "retrievable": true, 
            "sortable": false, 
            "facetable": false
        },
        {
            "name": "DescriptionVector",
            "type": "Collection(Edm.Single)",
            "searchable": true,
            "retrievable": true,
            "dimensions": 1536,
            "vectorSearchProfile": "my-vector-profile"
        },
        {
            "name": "Category", 
            "type": "Edm.String",
            "searchable": true, 
            "filterable": true, 
            "retrievable": true, 
            "sortable": true, 
            "facetable": true
        },
        {
            "name": "Tags",
            "type": "Collection(Edm.String)",
            "searchable": true,
            "filterable": true,
            "retrievable": true,
            "sortable": false,
            "facetable": true
        },
        {
            "name": "Address", 
            "type": "Edm.ComplexType",
            "fields": [
                {
                    "name": "City", "type": "Edm.String",
                    "searchable": true, "filterable": true, "retrievable": true, "sortable": true, "facetable": true
                },
                {
                    "name": "StateProvince", "type": "Edm.String",
                    "searchable": true, "filterable": true, "retrievable": true, "sortable": true, "facetable": true
                }
            ]
        },
        {
            "name": "Location",
            "type": "Edm.GeographyPoint",
            "searchable": false, 
            "filterable": true, 
            "retrievable": true, 
            "sortable": true, 
            "facetable": false
        }
    ],
    "vectorSearch": {
        "algorithms": [
            {
                "name": "my-hnsw-vector-config-1",
                "kind": "hnsw",
                "hnswParameters": 
                {
                    "m": 4,
                    "efConstruction": 400,
                    "efSearch": 500,
                    "metric": "cosine"
                }
            },
            {
                "name": "my-hnsw-vector-config-2",
                "kind": "hnsw",
                "hnswParameters": 
                {
                    "m": 4,
                    "metric": "euclidean"
                }
            },
            {
                "name": "my-eknn-vector-config",
                "kind": "exhaustiveKnn",
                "exhaustiveKnnParameters": 
                {
                    "metric": "cosine"
                }
            }
        ],
        "profiles": [      
            {
                "name": "my-vector-profile",
                "algorithm": "my-hnsw-vector-config-1"
            }
      ]
    },
    "semantic": {
        "configurations": [
            {
                "name": "my-semantic-config",
                "prioritizedFields": {
                    "titleField": {
                        "fieldName": "HotelName"
                    },
                    "prioritizedContentFields": [
                        { "fieldName": "Description" }
                    ],
                    "prioritizedKeywordsFields": [
                        { "fieldName": "Tags" }
                    ]
                }
            }
        ]
    }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 07:50:05