註
Azure AI 搜尋服務 可透過 Azure 入口網站、REST API 及 Azure SDK 取得。 它同時也是 Foundry IQ 的基礎,這是一個管理式知識層,能將企業內容轉化為可重複使用、權限感知的知識庫,供 Microsoft Foundry 入口網站中的代理使用。
Important
標記(預覽)的功能、能力或屬性不受服務等級協議涵蓋,也不建議用於生產工作負載,且在正式上架前可能會有所變動或受限。 Azure AI 搜尋服務 預覽條款適用於所有預覽功能,無論是獨立功能還是正式推出功能的一部分。
索引的SharePoint知識來源(預覽)會在Azure AI 搜尋服務中將SharePoint內容匯入代理檢索管線。 知識來源 獨立建立,並在 知識庫中被引用,並在 執行時查詢知識庫時作為基礎資料。
當你建立索引 SharePoint 知識來源時,你可以指定一個 SharePoint 連接字串、模型和屬性,以自動產生以下 Azure AI 搜尋服務 物件:
- 指向 SharePoint 網站且使用維持不變的連接字串的資料來源。 產生的資料來源遵循 SharePoint 索引器的
TenantId規則。 - 一套技能組合,可以分割並可選擇向量化多模態內容。
- 一個儲存豐富內容且符合代理檢索標準的索引。
- 使用先前物件來驅動編製索引和擴充管線的索引子。
產生的索引器符合 Microsoft 365 索引器的 SharePoint,其先決條件、支援的文件格式及限制同樣適用於索引化的 SharePoint 知識來源。 欲了解更多資訊,請參閱 SharePoint 索引器文件及索引器限制。 若所產生的技能組呼叫外部服務,該技能的輸入與服務限制也會適用。
使用支援
| Azure portal | Microsoft Foundry 入口 | .NET SDK | Python SDK | Java 開發套件 | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
先決條件
任何 區域內提供主動檢索的 Azure AI 搜尋服務 服務。
完成以下 SharePoint 索引器設定步驟:
步驟 1:啟用 Azure AI 搜尋服務0 的管理身份(僅用於無秘密認證;若使用用戶端秘密則跳過) 步驟 3:建立Microsoft Entra應用程式註冊 (應用程式權限方面,還需設定client secret 或 secretless authentication )
如果
contentExtractionMode是standard,請使用位於 Foundry Tools 中 Content Understanding 支援的區域 的 Microsoft Foundry 資源,以及https://<resource-name>.services.ai.azure.com端點。 部署嵌入模型,若啟用影像語言化,則部署多模態聊天模型。允許建立知識來源。 建議使用分配給你的使用者帳號的搜尋服務貢獻者和搜尋索引資料貢獻者角色來設定無密鑰認證,或使用管理員 API 金鑰。
若知識來源指定 Azure OpenAI 模型用於嵌入或影像文字化,搜尋服務必須具有 受控識別,且在 Microsoft Foundry 資源上具有 Cognitive Services User 權限。
如果你設定
networkAccessMode為private,請完成以下要求:使用 S2、S3、L1或L2的搜尋服務。
保留前述必要條件中所述的 SharePoint 連接字串、Microsoft Entra 應用程式及 SharePoint 權限。 SharePoint Online 不支援共享私人連結目標,因此私人模式不會讓這個來源連線變成私人。
對於每個受保護的模型端點,在搜尋服務上啟用管理身份,賦予其認知 服務使用者 角色,並建立並核准共享的私有連結。 Azure OpenAI 端點使用
foundry_account群組 ID,Foundry 資源端點則使用openai_account。
最新的
Azure.Search.Documents預覽套件:dotnet add package Azure.Search.Documents --prerelease對於無鑰匙認證,套件如下
Azure.Identity:dotnet add package Azure.Identity
最新的
azure-search-documents預覽套件:pip install --pre azure-search-documents對於無鑰匙認證,套件如下
azure-identity:pip install azure-identity
搜尋服務 REST API 的 2026-08-01 預覽 版。
對於無金鑰認證,請在
Authorization每個 HTTP 請求的標頭中加入 Microsoft 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}");
}
參考資料: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})")
參考資料: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));
參考資料: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))
參考資料:SearchIndexClient
### Get a knowledge source definition
GET {{search-url}}/knowledgesources/{{knowledge-source-name}}?api-version={{api-version}}
Authorization: Bearer {{token}}
參考資料:知識來源 - 取得
以下 JSON 是一個針對索引 SharePoint 知識來源的範例回應。
{
"name": "my-indexed-sharepoint-ks",
"kind": "indexedSharePoint",
"description": "A sample indexed SharePoint knowledge source",
"encryptionKey": null,
"indexedSharePointParameters": {
"connectionString": "<redacted>",
"containerName": "defaultSiteLibrary",
"query": null,
"ingestionParameters": {
"disableImageVerbalization": false,
"ingestionPermissionOptions": [],
"contentExtractionMode": "minimal",
"identity": null,
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"resourceUri": "<redacted>",
"deploymentId": "text-embedding-3-large",
"modelName": "text-embedding-3-large",
"authIdentity": null
}
},
"chatCompletionModel": null,
"ingestionSchedule": null,
"assetStore": null,
"aiServices": null
},
"createdResources": {
"datasource": "my-indexed-sharepoint-ks-datasource",
"indexer": "my-indexed-sharepoint-ks-indexer",
"skillset": "my-indexed-sharepoint-ks-skillset",
"index": "my-indexed-sharepoint-ks-index"
}
},
"indexedOneLakeParameters": null
}
建立知識來源
執行以下程式碼建立一個索引化的 SharePoint 知識來源。
// Create an IndexedSharePoint knowledge source
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.KnowledgeBases.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
}
};
var sharePointParams = new IndexedSharePointKnowledgeSourceParameters(
connectionString: sharePointConnectionString,
containerName: "defaultSiteLibrary")
{
IngestionParameters = ingestionParams
};
var knowledgeSource = new IndexedSharePointKnowledgeSource(
name: "my-indexed-sharepoint-ks",
indexedSharePointParameters: sharePointParams)
{
Description = "A sample indexed SharePoint knowledge source."
};
await indexClient.CreateOrUpdateKnowledgeSourceAsync(knowledgeSource);
Console.WriteLine($"Knowledge source '{knowledgeSource.Name}' created or updated successfully.");
# Create an indexed SharePoint knowledge source
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import IndexedSharePointKnowledgeSource, IndexedSharePointKnowledgeSourceParameters, KnowledgeBaseAzureOpenAIModel, AzureOpenAIVectorizerParameters, KnowledgeSourceContentExtractionMode
from azure.search.documents.knowledgebases.models import KnowledgeSourceIngestionParameters, KnowledgeSourceNetworkAccessMode, KnowledgeSourceAzureOpenAIVectorizer
index_client = SearchIndexClient(endpoint = "<search-endpoint>", credential = DefaultAzureCredential())
knowledge_source = IndexedSharePointKnowledgeSource(
name = "my-indexed-sharepoint-ks",
description = "A sample indexed SharePoint knowledge source.",
encryption_key = None,
indexed_share_point_parameters = IndexedSharePointKnowledgeSourceParameters(
connection_string = "connection_string",
container_name = "defaultSiteLibrary",
query = None,
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 = None
)
)
)
index_client.create_or_update_knowledge_source(knowledge_source)
print(f"Knowledge source '{knowledge_source.name}' created or updated successfully.")
參考資料:SearchIndexClient
### Create an indexed SharePoint knowledge source
PUT {{search-endpoint}}/knowledgesources/my-indexed-sharepoint-ks?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
Content-Type: application/json
{
"name": "my-indexed-sharepoint-ks",
"kind": "indexedSharePoint",
"description": "A sample indexed SharePoint knowledge source.",
"encryptionKey": null,
"indexedSharePointParameters": {
"connectionString": "{{sharepoint-federated-connection-string}}",
"containerName": "defaultSiteLibrary",
"query": null,
"ingestionParameters": {
"networkAccessMode": "public",
"identity": null,
"embeddingModel": {
"kind": "azureOpenAI",
"azureOpenAIParameters": {
"deploymentId": "text-embedding-3-large",
"modelName": "text-embedding-3-large",
"resourceUri": "{{aoai-endpoint}}"
}
},
"chatCompletionModel": null,
"disableImageVerbalization": false,
"ingestionSchedule": null,
"ingestionPermissionOptions": [],
"contentExtractionMode": "minimal"
}
}
}
參考資料:知識來源 - 建立或更新
在擷取期間保護 Azure 相依性
從 2026-08-01-preview API 版本開始,networkAccessMode 會控制為已編製索引的 SharePoint 知識來源所產生索引器的執行網路環境。 此設定只會影響資料擷取,不會變更知識庫擷取請求或回應。
networkAccessMode 預設為 public,以保留現有的公共網路行為。 當 networkAccessMode 為 private 時,產生的索引器會在 私有執行環境中執行。 它使用經核准的共享私有連結來存取支援的 Azure 相依性,例如 Azure OpenAI 模型及 Microsoft Foundry 資源。
Important
對於索引的 SharePoint 知識來源,私密模式僅適用於支援的 Azure 相依關係。 SharePoint Online 並非支援的共享私有連結目標,因此 SharePoint 的原始連結仍保持公開。
若要設定並驗證對支援的 Azure 相依性進行私密存取:
完成 私人網路的必要條件。
在建立知識來源的請求中,將
networkAccessMode設為private。 你只能在建立時設定這個屬性。 若要稍後更改,請刪除並重新建立知識來源。如果服務層級或執行時不支援私有執行,或沒有所需的共享私有連結,建立可能會失敗。
確認產生的索引器
executionEnvironment為private。確認每個必要的共用私人連結皆已獲核准,且以正確的相依性為目標。 僅成功建立並不代表連結已獲核准或已設定目標對象。
輪詢知識來源狀態直到
lastSynchronizationState.endTime有值為止。 確認itemsUpdatesFailed為0,然後驗證連接器專屬的來源內容。 如果相依項目無法存取,同步就會失敗。
使用各語言的自動分析器
自 2026-08-01-preview API 版本起,Blob、已建立索引的 OneLake,以及已建立索引的 SharePoint 知識來源可使用每種語言的自動分析器。 啟用後,Azure AI 搜尋服務 會偵測每個來源文件的語言,並自動套用對應的 Microsoft 語言分析器。 你不會在知識來源定義或查詢中指定分析器。
若要啟用各語言的自動分析器,請將 contentExtractionMode 設為 minimal,並在知識來源定義中設定 ingestionParameters.aiServices。
對於無金鑰驗證,省略aiServices.apiKey並將 Microsoft Foundry 資源中的認知服務使用者角色指派到搜尋服務的管理身份上。 對於基於金鑰的認證,請設定 aiServices.apiKey 為 Foundry 資源的有效金鑰。
支援下列語言:
- English
- 日本
- 法語
- 西班牙語
- 德語
- 荷蘭語
- 義大利語
- 巴西葡萄牙文
- 歐洲葡萄牙語
- 簡體中文
- 繁體中文
- 韓語
對於多語言內容,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);
參考資料: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))
參考資料: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
}
}
註
kind屬性和currentSynchronizationState.errors[]陣列提供文件層級錯誤細節,並自 2026-04-01 起於 API 版本中提供。 對於較早期的 API 版本,這些欄位不會回傳。
lastSynchronizationState.status這個欄位也是在 2026-04-01 新增的。
檢視產生的物件
當你建立這個知識來源時,Azure AI 搜尋服務 會自動產生資料來源、技能集、索引器和索引。 建立回應會列出 createdResources 下的每個物件。
這些物件依據固定模板產生,名稱則取自知識來源的名稱。 你無法更改物件名稱。 避免直接編輯這些物件,因為變更可能會產生錯誤或不相容,破壞索引器管線。
你可以使用 Azure 入口網站來驗證物件建立。 工作流程如下:
檢查索引器上的成功或失敗訊息。 連線或配額錯誤會出現在這裡。
請檢查資料來源以確認與資料儲存的連結。 連線會依據您設定知識來源的方式,使用連接字串或受控識別。
檢查技能組,了解系統如何將你的內容分塊,以及是否選擇性地進行向量化。
檢查索引,了解你的內容如何被索引並展示以便檢索,包括哪些欄位可搜尋和篩選,哪些欄位儲存向量以便相似度搜尋。 使用搜尋總管對產生的索引執行查詢。
指派至知識庫
如果你對知識來源感到滿意,就 把它加入知識庫。
對於指定索引SharePoint知識來源的知識庫,請務必將 includeReferenceSourceData 設為 true。 此步驟是將原始文件網址拉入引用中所必需的。
查詢知識庫
設定知識庫後, 呼叫擷取動作或 MCP 端點 查詢知識來源。 選擇符合你情境的配置。
強制執行文件層級權限
若要強制執行文件層級權限,請在建立此知識來源時設定 ingestionPermissionOptions,然後在擷取要求中包含使用者的存取權杖。 更多資訊請參閱查詢時強制執行權限(預覽)。
關於索引 SharePoint 權限查詢中遺失、意外或失敗的結果,請參見故障排除 SharePoint 權限過濾。
呈現文件內嵌影像
要在答案綜合回應中呈現文件嵌入的影像(如圖表或掃描圖),請在此知識來源上設定 assetStore ,然後在知識庫啟用影像服務。 設定時 ingestionPermissionOptions 不支援影像服務。 如需詳細資訊,請參閱 在 agentic retrieval 中呈現文件內嵌影像(預覽)。
刪除知識來源
在刪除知識來源之前,必須刪除所有引用該來源的知識庫,或更新知識庫定義以移除該參考。 對於產生索引與索引管線的知識來源,所有 產生的物件 也會被刪除。 不過,如果你用現有的索引建立知識來源,你的索引不會被刪除。
如果你嘗試刪除正在使用的知識來源,該動作會失敗,並回傳一份受影響的知識庫清單。
刪除知識來源:
取得你搜尋服務中所有知識庫的清單。
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}"); }參考資料: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);參考資料: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.");參考資料:SearchIndexClient
刪除知識來源。
await indexClient.DeleteKnowledgeSourceAsync(knowledgeSourceName); System.Console.WriteLine($"Knowledge source '{knowledgeSourceName}' deleted successfully.");參考資料: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}")參考資料: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)參考資料: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.")參考資料: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.")參考資料: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}}參考資料:知識來源 - 刪除
已知錯誤
產生的 SharePoint 資料來源與索引器使用與直接設定的 SharePoint 索引器相同的 Microsoft Entra 租戶驗證與認證行為。 對於與租用戶相關的失敗,請檢閱所產生之索引子的狀態與執行記錄,然後依照Invalid AAD tenant補救步驟進行處理。