你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
注意
Azure AI 搜索可通过Azure门户、REST API 和Azure SDK获取。 它也是 Foundry IQ 的基础;Foundry IQ 是一个托管式知识层,可将企业内容转化为供 Microsoft Foundry 门户中的智能体使用的、可复用且具备权限感知能力的知识库。
Important
标记为“预览”的特性、功能或属性不受服务级别协议 (SLA) 保障,不建议用于生产工作负载,并且在正式发布之前可能会更改或受到限制。 Azure AI 搜索预览条款适用于所有预览功能,无论是独立功能还是正式版功能的一部分。
blob 知识来源将 Azure Blob 存储或 ADLS Gen2 内容引入 Azure AI 搜索中的智能体检索管道。 知识库是在运行时查询知识库时独立创建的、在知识库中引用的,并用作基础数据。
创建 Blob 知识源时,请指定外部数据源、模型和属性以自动生成以下Azure AI 搜索对象:
- 表示 Blob 容器的数据源。
- 一个技能组,用于将多模态内容从容器中分块和选择性地向量化。
- 存储扩充内容并满足代理检索条件的索引。
- 使用前面的对象驱动索引和扩充管道的索引器。
生成的索引 器符合 Blob 索引器,其先决条件、支持的文档格式和限制也适用于 Blob 知识源。 有关详细信息,请参阅 Blob 索引器文档 和 索引器限制。 如果生成的技能集调用外部服务,该技能的输入和服务限制也适用。
注意
如果在Azure 存储的文档(blob)级别指定了用户访问,知识源可以将权限元数据转发到Azure AI 搜索中的索引内容。 有关详细信息,请参阅 ADLS Gen2 权限元数据(预览版)或 Blob RBAC 范围(预览版)。
使用支持
| Azure 门户 | Microsoft Foundry 门户 | .NET SDK | Python SDK | Java SDK | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
先决条件
在任意提供代理检索功能的区域中提供的 Azure AI 搜索服务。
一个 Blob 容器,支持文本内容的内容类型。 对于可选的图像语言化,支持的内容类型取决于聊天完成模型是否可以分析和描述图像文件。
如果
standard为contentExtractionMode,请使用位于 Foundry Tools 中内容理解支持的区域内且具有https://<resource-name>.services.ai.azure.com终结点的 Microsoft Foundry 资源。 该资源必须具有嵌入模型部署;如果启用了图像描述功能,还必须具有多模态聊天模型部署。创建知识源的权限。 使用分配给用户帐户的搜索服务参与者和搜索索引数据参与者角色(建议)或使用管理员 API 密钥配置无密钥身份验证。
具有源存储帐户范围的Storage Blob Data Reader以及 Microsoft Foundry 资源上的 Cognitive Services User 的搜索服务的托管标识。 若在不同的存储帐户中配置资产存储,还需在该存储帐户范围内分配 Storage Blob Data Contributor 角色。 如果源容器和资产容器属于同一帐户,存储 Blob 数据参与者 同时提供对源的读取访问权限以及对资产存储的读/写访问权限。
如果将
networkAccessMode设置为private,请完成以下要求:在搜索服务上启用系统分配或用户分配的托管标识,为其授予存储帐户上的存储 Blob 数据读取者角色,并使用
ResourceId=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account>连接字符串。 对于用户分配的标识,还设置ingestionParameters.identity。为存储帐户创建并批准使用
blob组 ID 的共享专用链接。 对于 ADLS Gen2,请创建并批准blob和dfs这两个共享专用链接。为每个受保护的模型终结点创建和批准共享专用链接。 将
openai_account组 ID 用于 Azure OpenAI 终结点,将foundry_account用于 Foundry 资源终结点。
所需
Azure.Search.Documents软件包:对于
2026-08-01-preview功能,最新的预览包:dotnet add package Azure.Search.Documents --prerelease对于
2026-04-01功能,最新稳定版软件包:dotnet add package Azure.Search.Documents
对于无密钥身份验证,请使用
Azure.Identity软件包:dotnet add package Azure.Identity
所需
azure-search-documents软件包:对于
2026-08-01-preview功能,最新的预览包:pip install --pre azure-search-documents对于
2026-04-01功能,最新稳定版软件包:pip install azure-search-documents
对于无密钥身份验证,请使用
azure-identity软件包:pip install azure-identity
所需的搜索服务 REST API 版本:
对于预览功能: 2026-08-01-preview
对于正式发布的功能:2026-04-01
对于无密钥身份验证,请在每个 HTTP 请求的标头中包含
AuthorizationMicrosoft Entra ID令牌。
检查现有知识源
知识源是顶级可重用对象。 了解现有知识源有助于重复使用或命名新对象。
运行以下代码,按名称和类型列出知识源。
// List knowledge sources by name and type
using Azure.Search.Documents.Indexes;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential);
var knowledgeSources = indexClient.GetKnowledgeSourcesAsync();
Console.WriteLine("Knowledge Sources:");
await foreach (var ks in knowledgeSources)
{
Console.WriteLine($" Name: {ks.Name}, Type: {ks.GetType().Name}");
}
Reference:SearchIndexClient
# List knowledge sources by name and type
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key"))
for ks in index_client.list_knowledge_sources():
print(f" - {ks.name} ({ks.kind})")
Reference:SearchIndexClient
### List knowledge sources by name and type
GET {{search-url}}/knowledgesources?api-version={{api-version}}&$select=name,kind
Authorization: Bearer {{token}}
参考:知识源 - 列表
还可以按名称返回单个知识源以查看其 JSON 定义。
using Azure.Search.Documents.Indexes;
using System.Text.Json;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential);
// Specify the knowledge source name to retrieve
string ksNameToGet = "earth-knowledge-source";
// Get its definition
var knowledgeSourceResponse = await indexClient.GetKnowledgeSourceAsync(ksNameToGet);
var ks = knowledgeSourceResponse.Value;
// Serialize to JSON for display
var jsonOptions = new JsonSerializerOptions
{
WriteIndented = true,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
};
Console.WriteLine(JsonSerializer.Serialize(ks, ks.GetType(), jsonOptions));
Reference:SearchIndexClient
# Get a knowledge source definition
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
import json
index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key"))
ks = index_client.get_knowledge_source("knowledge_source_name")
print(json.dumps(ks.as_dict(), indent = 2))
Reference:SearchIndexClient
### Get a knowledge source definition
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}}
Authorization: Bearer {{token}}
参考:知识源 - 获取
以下 JSON 是 Blob 知识源的示例响应。
{
"name": "my-blob-ks",
"kind": "azureBlob",
"description": "A sample blob knowledge source.",
"encryptionKey": null,
"azureBlobParameters": {
"connectionString": "<REDACTED>",
"containerName": "blobcontainer",
"folderPath": null,
"isADLSGen2": false,
"ingestionParameters": {
"disableImageVerbalization": false,
"ingestionPermissionOptions": [],
"contentExtractionMode": "standard",
"identity": null,
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<REDACTED>",
"deploymentId": "text-embedding-3-large",
"modelName": "text-embedding-3-large",
"authIdentity": null
}
},
"chatCompletionModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<aoai-endpoint>",
"deploymentId": "gpt-5-mini",
"modelName": "gpt-5-mini",
"authIdentity": null
}
},
"ingestionSchedule": null,
"assetStore": null,
"aiServices": {
"uri": "<aoai-endpoint>",
}
},
"createdResources": {
"datasource": "my-blob-ks-datasource",
"indexer": "my-blob-ks-indexer",
"skillset": "my-blob-ks-skillset",
"index": "my-blob-ks-index"
}
}
}
注意
敏感信息经过修订。 生成的资源显示在响应的末尾。
创建知识源
运行以下代码以创建 Blob 知识源。
// Create a blob knowledge source
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.KnowledgeBases.Models;
using Azure.Search.Documents.Models;
using Azure.Identity;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), new DefaultAzureCredential());
var chatCompletionParams = new AzureOpenAIVectorizerParameters
{
ResourceUri = new Uri(aoaiEndpoint),
DeploymentName = aoaiGptDeployment,
ModelName = aoaiGptModel
};
var embeddingParams = new AzureOpenAIVectorizerParameters
{
ResourceUri = new Uri(aoaiEndpoint),
DeploymentName = aoaiEmbeddingDeployment,
ModelName = aoaiEmbeddingModel
};
var ingestionParams = new KnowledgeSourceIngestionParameters
{
NetworkAccessMode = KnowledgeSourceNetworkAccessMode.Public,
DisableImageVerbalization = false,
ChatCompletionModel = new KnowledgeBaseAzureOpenAIModel(azureOpenAIParameters: chatCompletionParams),
EmbeddingModel = new KnowledgeSourceAzureOpenAIVectorizer
{
AzureOpenAIParameters = embeddingParams
},
IngestionPermissionOptions = new List<KnowledgeSourceIngestionPermissionOption>
{
KnowledgeSourceIngestionPermissionOption.UserIds,
KnowledgeSourceIngestionPermissionOption.GroupIds
}
};
var blobParams = new AzureBlobKnowledgeSourceParameters(
connectionString: connectionString,
containerName: containerName
)
{
IsAdlsGen2 = false,
IngestionParameters = ingestionParams
};
var knowledgeSource = new AzureBlobKnowledgeSource(
name: "my-blob-ks",
azureBlobParameters: blobParams
)
{
Description = "This knowledge source pulls from a blob storage container."
};
await indexClient.CreateOrUpdateKnowledgeSourceAsync(knowledgeSource);
Console.WriteLine($"Knowledge source '{knowledgeSource.Name}' created or updated successfully.");
Reference:SearchIndexClient、 AzureBlobKnowledgeSource
# Create a blob knowledge source
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import AzureBlobKnowledgeSource, AzureBlobKnowledgeSourceParameters, KnowledgeBaseAzureOpenAIModel, AzureOpenAIVectorizerParameters, KnowledgeSourceAzureOpenAIVectorizer, KnowledgeSourceContentExtractionMode, KnowledgeSourceIngestionParameters
from azure.search.documents.knowledgebases.models import KnowledgeSourceNetworkAccessMode
index_client = SearchIndexClient(endpoint = "<search-endpoint>", credential = DefaultAzureCredential())
knowledge_source = AzureBlobKnowledgeSource(
name = "my-blob-ks",
description = "This knowledge source pulls from a blob storage container.",
encryption_key = None,
azure_blob_parameters = AzureBlobKnowledgeSourceParameters(
connection_string = "blob_connection_string",
container_name = "blob_container_name",
folder_path = None,
is_adls_gen2 = False,
ingestion_parameters = KnowledgeSourceIngestionParameters(
network_access_mode = KnowledgeSourceNetworkAccessMode.PUBLIC,
identity = None,
disable_image_verbalization = False,
chat_completion_model = KnowledgeBaseAzureOpenAIModel(
azure_open_ai_parameters = AzureOpenAIVectorizerParameters(
resource_url = "<aoai-endpoint>",
deployment_name = "<aoai-gpt-deployment>",
model_name = "<aoai-gpt-model>",
)
),
embedding_model = KnowledgeSourceAzureOpenAIVectorizer(
azure_open_ai_parameters=AzureOpenAIVectorizerParameters(
resource_url = "<aoai-endpoint>",
deployment_name = "<aoai-embedding-deployment>",
model_name = "<aoai-embedding-model>",
)
),
content_extraction_mode = KnowledgeSourceContentExtractionMode.MINIMAL,
ingestion_schedule = None,
ingestion_permission_options = ["user_ids", "group_ids"]
)
)
)
index_client.create_or_update_knowledge_source(knowledge_source)
print(f"Knowledge source '{knowledge_source.name}' created or updated successfully.")
Reference:SearchIndexClient
### Create a blob knowledge source
PUT {{search-endpoint}}/knowledgesources/my-blob-ks?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
Content-Type: application/json
{
"name": "my-blob-ks",
"kind": "azureBlob",
"description": "This knowledge source pulls from a blob storage container.",
"encryptionKey": null,
"azureBlobParameters": {
"connectionString": "ResourceId=<storage-resource-id>",
"containerName": "<blob-container-name>",
"folderPath": null,
"isADLSGen2": false,
"ingestionParameters": {
"networkAccessMode": "public",
"identity": null,
"disableImageVerbalization": null,
"chatCompletionModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "{{aoai-gpt-deployment}}",
"modelName": "{{aoai-gpt-model}}"
}
},
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "{{aoai-endpoint}}",
"deploymentId": "{{aoai-embedding-deployment}}",
"modelName": "{{aoai-embedding-model}}"
}
},
"contentExtractionMode": "minimal",
"ingestionSchedule": null,
"ingestionPermissionOptions": ["userIds", "groupIds"]
}
}
}
参考:知识源 - 创建或更新
注意
若要使用 ingestionPermissionOptions 强制执行文档级权限,请使用 2026-08-01-preview API 版本。 2026-04-01 API 版本不支持此功能。
限制引入专用网络(预览版)
从 2026-08-01-preview API 版本开始, networkAccessMode 控制为 Blob 知识源运行生成的索引器的网络环境。 此设置仅影响引入,不会更改知识库检索请求或响应。
networkAccessMode 默认为 public保留现有公共网络行为。 如果 networkAccessMode 为 private,生成的索引器在 专用执行环境中运行。 它使用批准的共享专用链接访问 Azure Blob 存储 或 ADLS Gen2 源连接,并支持Azure依赖项,例如Azure OpenAI 模型和 Microsoft Foundry 资源。
配置和验证专用网络访问:
完成 专用网络先决条件。
在知识源创建请求中,将
networkAccessMode设置为private。 只能在创建过程中设置此属性。 若要稍后对其进行更改,请删除并重新创建知识源。如果服务层或运行时不支持专用执行,或者所需的共享专用链接不存在,则创建可能会失败。
确认生成的索引器
executionEnvironment为private.确认每个必需的共享专用链接都已获得批准,并针对正确的依赖项。 仅凭成功创建并不能确认链接已获批准或定向设置已生效。
轮询知识源状态,直到
lastSynchronizationState.endTime具有值。 确认itemsUpdatesFailed为0,然后验证特定于连接器的源内容。 如果无法访问依赖项,同步将失败。
使用按语言自动选择的分析器(预览版)
从 2026-08-01-preview API 版本开始,针对 Blob、已编制索引的 OneLake 以及已编制索引的 SharePoint 知识源提供了按语言的自动分析器。 启用后,Azure AI 搜索检测每个源文档的语言,并自动应用匹配Microsoft语言分析器。 不会在知识源定义或查询中指定分析器。
若要启用每种语言的自动分析器,请在知识源定义中设置为contentExtractionModeminimal和配置ingestionParameters.aiServices。
对于无密钥身份验证,请省略 aiServices.apiKey,并在 Microsoft Foundry 资源上将 认知服务用户 角色分配给搜索服务的托管标识。 对于基于密钥的身份验证,请将 aiServices.apiKey 设置为您的 Foundry 资源的有效密钥。
支持以下语言:
- English
- 日语
- French
- Spanish
- German
- 荷兰语
- Italian
- 巴西葡萄牙语
- 欧洲葡萄牙语
- 简体中文
- 繁体中文
- Korean
对于多语言内容,Azure AI 搜索根据检测到的主要语言选择分析器。 当语言不受支持或不确定时,它使用标准分析器。
启用自动每种语言分析器时,Azure AI 搜索向生成的索引架构添加每个支持语言的语言特定内容字段,无论数据是否包含这些语言中的文档。 在摄取过程中,文档会根据检测到的语言被路由到相应的语言专用字段。
未使用的语言字段不包含索引内容,并且存储影响最小,但它们仍然是索引架构的一部分,并计入索引字段限制。 规划索引设计、字段计数和存储要求时,请考虑其他字段。 有关更多信息,请参阅索引限制和估算和管理搜索服务的容量。
语言检测在超出免费 AI 增强额度后将开始收费。 有关详细信息,请参阅 免费扩充。
检查摄取状态
运行以下代码来监视引入进度和运行状况,包括知识源类型以及生成索引器管道并填充搜索索引的知识源的详细索引错误。
using Azure.Search.Documents.Indexes;
using System.Text.Json;
var indexClient = new SearchIndexClient(new Uri(searchEndpoint), new AzureKeyCredential(apiKey));
// Get knowledge source ingestion status
var statusResponse = await indexClient.GetKnowledgeSourceStatusAsync(knowledgeSourceName);
var status = statusResponse.Value;
// Serialize to JSON for display
var json = JsonSerializer.Serialize(status, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(json);
Reference:SearchIndexClient
# Check knowledge source ingestion status
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
import json
index_client = SearchIndexClient(endpoint="search_url", credential=AzureKeyCredential("api_key"))
status = index_client.get_knowledge_source_status("knowledge_source_name")
print(json.dumps(status.as_dict(), indent=2))
Reference:SearchIndexClient
### Check knowledge source ingestion status
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}/status?api-version={{api-version}}
Authorization: Bearer {{token}}
Content-Type: application/json
参考:知识源 - 获取状态
包含引入参数且正在主动引入内容的请求的响应可能如以下示例所示。
{
"kind": "azureBlob",
"synchronizationStatus": "active",
"synchronizationInterval": "1d",
"currentSynchronizationState": {
"startTime": "2026-04-10T19:30:00Z",
"itemUpdatesProcessed": 1100,
"itemsUpdatesFailed": 100,
"itemsSkipped": 1100,
"errors": [
{
"key": "Item id 1",
"docURL": "https://contoso.blob.core.windows.net/contracts/2024/Q4/doc-00023.csv",
"statusCode": 400,
"componentName": "DocumentExtraction.AzureBlob.MyDataSource",
"errorMessage": "Could not read the value of column 'foo' at index '0'.",
"details": "The file could not be parsed.",
"documentationLink": "https://go.microsoft.com/fwlink/?linkid=2049388"
}
]
},
"lastSynchronizationState": {
"status": "partialSuccess",
"startTime": "2026-04-09T19:30:00Z",
"endTime": "2026-04-09T19:40:01Z",
"itemUpdatesProcessed": 1100,
"itemsUpdatesFailed": 100,
"itemsSkipped": 1100,
"errors": null
},
"statistics": {
"totalSynchronizations": 25,
"averageSynchronizationDuration": "00:15:20",
"averageItemsProcessedPerSynchronization": 500
}
}
注意
从 2026-04-01 API 版本开始,文档级错误详细信息的 kind 属性和 currentSynchronizationState.errors[] 数组即可使用。 对于早期 API 版本,不会返回这些字段。 该 lastSynchronizationState.status 字段也是 2026-04-01 中的新增字段。
查看生成的对象
创建此知识源时,Azure AI 搜索自动生成数据源、技能集、索引器和索引。 创建响应将列出下 createdResources的每个对象。
这些对象根据固定模板生成,其名称基于知识源的名称。 无法更改对象名称。 避免直接编辑这些对象,因为更改可能会引入中断索引器管道的错误或不兼容。
可以使用Azure门户验证对象创建。 工作流为:
检查索引器是否有成功或失败的消息。 这里会显示连接错误或配额错误。
检查数据源以验证与数据存储的连接。 该连接使用连接字符串或托管标识,具体取决于你如何配置知识源。
检查技能集以查看内容是如何分块和选择性的矢量化的。
检查索引以了解您的内容是如何被编制索引和公开以供检索的,包括哪些字段可供搜索和筛选,以及哪些字段存储用于相似性搜索的向量。 使用搜索资源管理器针对生成的索引运行查询。
分配给知识库
如果对知识源感到满意, 请将其添加到知识库。
查询知识库
配置知识库后, 调用检索操作或 MCP 终结点 来查询知识源。 选择与方案匹配的配置。
强制实施文档级权限(预览版)
若要强制实施文档级权限,请在创建此知识源时设置 ingestionPermissionOptions ,然后在检索请求中包含用户的访问令牌。 有关详细信息,请参阅在查询时强制实施权限(预览版)。
显示文档嵌入图像(预览版)
若要在答案合成响应中显示文档嵌入的图像(如图表或扫描),请对此知识源进行配置 assetStore ,然后在知识库上启用图像服务。 配置了 ingestionPermissionOptions 时,不支持图像服务。 有关详细信息,请参阅代理检索中Surface文档嵌入图像(预览版)。
删除知识源
在删除知识库之前,必须删除引用它的任何知识库或更新知识库定义以删除引用。 对于生成索引和索引器管道的知识源,也会删除所有 生成的对象 。 但是,如果使用现有索引创建知识源,则不会删除索引。
如果尝试删除正在使用的知识源,该操作将失败并返回受影响的知识库列表。
删除知识源:
获取搜索服务上所有知识库的列表。
using Azure.Search.Documents.Indexes; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); var knowledgeBases = indexClient.GetKnowledgeBasesAsync(); Console.WriteLine("Knowledge Bases:"); await foreach (var kb in knowledgeBases) { Console.WriteLine($" - {kb.Name}"); }Reference:SearchIndexClient
示例响应可能如下所示:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }获取单个知识库定义以检查知识源引用。
using Azure.Search.Documents.Indexes; using System.Text.Json; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); // Specify the knowledge base name to retrieve string kbNameToGet = "earth-knowledge-base"; // Get a specific knowledge base definition var knowledgeBaseResponse = await indexClient.GetKnowledgeBaseAsync(kbNameToGet); var kb = knowledgeBaseResponse.Value; // Serialize to JSON for display string json = JsonSerializer.Serialize(kb, new JsonSerializerOptions { WriteIndented = true }); Console.WriteLine(json);Reference:SearchIndexClient
示例响应可能如下所示:
{ "Name": "earth-knowledge-base", "KnowledgeSources": [ { "Name": "earth-knowledge-source" } ], "Models": [ {} ], "RetrievalReasoningEffort": {}, "OutputMode": {}, "ETag": "\u00220x8DE278629D782B3\u0022", "EncryptionKey": null, "Description": null, "RetrievalInstructions": null, "AnswerInstructions": null }删除知识库,或者如果有多个知识库,请更新知识库以删除源。 此示例显示删除。
using Azure.Search.Documents.Indexes; var indexClient = new SearchIndexClient(new Uri(searchEndpoint), credential); await indexClient.DeleteKnowledgeBaseAsync(knowledgeBaseName); System.Console.WriteLine($"Knowledge base '{knowledgeBaseName}' deleted successfully.");Reference:SearchIndexClient
删除知识源。
await indexClient.DeleteKnowledgeSourceAsync(knowledgeSourceName); System.Console.WriteLine($"Knowledge source '{knowledgeSourceName}' deleted successfully.");Reference:SearchIndexClient
获取搜索服务上所有知识库的列表。
# Get knowledge bases from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) print("Knowledge Bases:") for kb in index_client.list_knowledge_bases(): print(f" - {kb.name}")Reference:SearchIndexClient
示例响应可能如下所示:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }获取单个知识库定义以检查知识源引用。
# Get a knowledge base definition from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) kb = index_client.get_knowledge_base("knowledge_base_name") print(kb)Reference:SearchIndexClient
示例响应可能如下所示:
{ "name": "my-kb", "description": null, "retrievalInstructions": null, "answerInstructions": null, "outputMode": null, "knowledgeSources": [ { "name": "my-blob-ks" } ], "models": [], "encryptionKey": null, "retrievalReasoningEffort": { "kind": "low" } }删除知识库,或者如果有多个知识库,请更新知识库以删除源。 此示例显示删除。
# Delete a knowledge base from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) index_client.delete_knowledge_base("knowledge_base_name") print(f"Knowledge base deleted successfully.")Reference:SearchIndexClient
删除知识源。
# Delete a knowledge source from azure.core.credentials import AzureKeyCredential from azure.search.documents.indexes import SearchIndexClient index_client = SearchIndexClient(endpoint = "search_url", credential = AzureKeyCredential("api_key")) index_client.delete_knowledge_source("knowledge_source_name") print(f"Knowledge source deleted successfully.")Reference:SearchIndexClient
获取搜索服务上所有知识库的列表。
### Get knowledge bases GET {{search-url}}/knowledgebases?api-version={{api-version}}&$select=name Authorization: Bearer {{token}}参考:知识库 - 列表
示例响应可能如下所示:
{ "@odata.context": "https://my-search-service.search.windows.net/$metadata#knowledgebases(name)", "value": [ { "name": "my-kb" }, { "name": "my-kb-2" } ] }获取单个知识库定义以检查知识源引用。
### Get a knowledge base definition GET {{search-url}}/knowledgebases/{{knowledge-base-name}}?api-version={{api-version}} Authorization: Bearer {{token}}参考:知识库 - 获取
示例响应可能如下所示:
{ "name": "my-kb", "description": null, "retrievalInstructions": null, "answerInstructions": null, "outputMode": null, "knowledgeSources": [ { "name": "my-blob-ks" } ], "models": [], "encryptionKey": null, "retrievalReasoningEffort": { "kind": "low" } }删除知识库,或者如果有多个知识库,请更新知识库以删除源。 此示例显示删除。
### Delete a knowledge base DELETE {{search-url}}/knowledgebases/{{knowledge-base-name}}?api-version={{api-version}} Authorization: Bearer {{token}}参考:知识库 - 删除
删除知识源。
### Delete a knowledge source DELETE {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}} Authorization: Bearer {{token}}参考:知识源 - 删除