Note
Azure AI 搜尋服務 可透過 Azure 入口網站、REST API 及 Azure SDK 取得。 它同時也是 Foundry IQ 的基礎,這是一個管理式知識層,能將企業內容轉化為可重複使用、權限感知的知識庫,供 Microsoft Foundry 入口網站中的代理使用。
Important
標記(預覽)的功能、能力或屬性不受服務等級協議涵蓋,也不建議用於生產工作負載,且在正式上架前可能會有所變動或受限。 Azure AI 搜尋服務 預覽條款適用於所有預覽功能,無論是獨立功能還是正式推出功能的一部分。
當您連接 Work IQ 時,可能會產生成本,資料也可能被傳送到Azure合規邊界之外,並依照適用的服務條款和資料處理政策處理。
Work IQ 知識來源(預覽)將 Work IQ 連接到 Azure AI 搜尋服務 中的代理檢索管線。 知識來源 獨立建立,並在 知識庫中被引用,並在 執行時查詢知識庫時作為基礎資料。
Work IQ 從您的 Microsoft 365 內容中提取組織智慧,包括文件、電子郵件、會議以及 Microsoft 365 應用程式中的活動。
與索引知識來源不同,Work IQ 知識來源會在檢索時直接查詢即時資料。 不需要資料擷取流程。 查詢需要使用為您的 Microsoft Entra 應用程式註冊所核發的使用者存取權杖。 Azure AI 搜尋服務 會將該代幣交換成委派的 Work IQ 代幣,並代表使用者呼叫 Work IQ。
Warning
在此預覽版中,Work IQ 知識來源可能會使用執行動作的 Work IQ 功能,而不只是擷取資訊。 請謹慎使用,限制可信應用程式與使用者的存取權限,並在啟用前檢視情境的權限與治理控制。
使用支援
| Azure portal | Microsoft Foundry 入口網站 | .NET SDK | Python SDK | Java 開發套件 | JavaScript SDK | REST API |
|---|---|---|---|---|---|---|
| ❌ | ❌ | ✔️ | ✔️ | ❌ | ❌ | ✔️ |
先決條件
任何 區域內提供主動檢索的 Azure AI 搜尋服務 服務。
這是一套基於使用量的 Work IQ 計費計畫,在 Copilot Studio 中設定,並搭配 Azure 訂閱和資源群組。 將每位查詢 Work IQ 的使用者指派給計費方案。
您的 Microsoft Entra 租戶已啟用 Work IQ。 帳單設定完成後,Microsoft Entra 全球管理員會完成此一次性設定。
一個客戶端應用程式,負責登入使用者並發送擷取請求。
各項應用程式設定動作建議的 Microsoft Entra 角色:
需要應用程式開發人員角色,才能建立應用程式註冊。
應用程式註冊擁有者或受支援的系統管理員角色,才能 建立其同盟識別憑證。
需要雲端應用程式系統管理員或應用程式系統管理員角色,才能為
WorkIQAgent.Ask委派權限授與全租用戶系統管理員同意。
允許建立知識來源。 設定無金鑰驗證,並將搜尋服務參與者角色指派給您的使用者帳戶(建議),或使用管理員 API 金鑰。
最新的
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 令牌。
資料治理與合規
在啟用 Work IQ 檢索前,請先檢視 Microsoft Copilot 的資料、隱私與安全性。
資料使用與隱私
透過 Microsoft Graph 存取的提示、回應與資料並未用於訓練基礎語言模型。
存取控制
Work IQ 對每個請求都套用 Microsoft 365 權限。 檢索只會回傳登入使用者有權限存取的組織資料。
資料駐留與合規
請檢視 Microsoft 365 文件中的資料駐留、隱私、安全及合規承諾,適用於您的組織與情境。
設定 Microsoft Entra 驗證
從 API 版本開始2026-08-01-preview,每個 Work IQ 知識來源都使用客戶擁有的 Microsoft Entra 應用程式註冊來進行認證。
在查詢時,認證的運作方式如下:
- 用戶端應用程式會登入使用者,並將使用者聲明發送到 Azure AI 搜尋服務。
- 搜尋服務的受控識別會透過同盟憑證,以客戶所擁有的應用程式身分進行驗證。
- Azure AI 搜尋服務 會以委派的 Work IQ 令牌交換使用者的聲明,並代表已登入的使用者呼叫 Work IQ。
Work IQ 知識來源中不會儲存任何客戶端秘密。 先設定應用程式及其權限一次,然後為每個使用該應用程式的搜尋服務身份建立聯邦憑證。
設定 Work IQ 應用程式註冊
若要設定 Azure AI 搜尋服務 用來呼叫 Work IQ 的客戶自有應用程式:
在你想管理 Work IQ 同意的 Microsoft Entra 租戶中註冊一個應用程式。 在 [支援的帳戶類型] 區段中,選取 [僅限此組織目錄中的帳戶]。
在應用程式註冊的 概覽 頁面,複製 應用程式(客戶端)ID 與 目錄(租戶)ID。 你需要應用程式 ID 來設定 Work IQ 驗證,並需要租用戶 ID 來登入包含該應用程式註冊的租用戶。
在應用程式註冊的 公開 API 頁面上,新增必要的委派範圍,其名稱必須完全為
access_as_user。 使用這個小寫名字;不要用其他範圍名稱替代。 完整範圍為api://<application-client-id>/access_as_user。在應用程式註冊的 API 權限頁面,選擇「新增我組織使用的權限 > API」。
搜尋 Work IQ (應用程式 ID
fdcc1f02-fc51-4226-8753-f668596af7f7),選擇 委派權限>WorkIQAgent.Ask,然後選擇 新增權限。請讓具備先決條件中所列同意角色的系統管理員,在同一頁面上選取 為 [您的租用戶] 授與管理員同意。 此授權允許應用程式將使用者聲明交換為委派的 Work IQ 權杖。
設定搜尋服務身份
要設定 Azure AI 搜尋服務 用來認證為你的 Work IQ 應用程式的身份:
在您的搜尋服務中啟用系統指派的管理身份。 如果你無法使用系統指派的身份,請設定一個使用者指定的身份。 不支援擁有多個使用者指派身份且沒有系統分配身份的搜尋服務。
在搜尋服務的 身份 頁面,複製 物件(主體)ID。 聯邦憑證使用此值作為其
subject。前往 Microsoft Entra ID> 的概觀,然後複製租用戶識別碼。 聯邦憑證在其網址中使用此值
issuer。
建立聯邦憑證
要為搜尋服務身份建立聯邦憑證:
建立名為
credential.json的檔案。 將<search-service-tenant-id>、<search-service-principal-id>和<search-service-name>替換為你搜尋服務的值。{ "name": "<search-service-name>-identity", "issuer": "https://login.microsoftonline.com/<search-service-tenant-id>/v2.0", "subject": "<search-service-principal-id>", "audiences": ["api://AzureADTokenExchange"] }憑證名稱必須在應用程式註冊時是唯一的。 該
subject值必須與管理身份主體 ID 完全一致。 不匹配是在你查詢時出現,而不是建立知識來源時。用包含應用程式註冊的租戶登入 Azure CLI。
az login --tenant <app-tenant-id> --allow-no-subscriptions建立聯邦憑證。
az ad app federated-credential create --id <application-client-id> --parameters credential.json --query id --output tsv複製指令輸出。 當你建立 Work IQ 知識來源時,請將此值用於
federatedCredentialId。
每個聯邦憑證信任一個受管理身份主體 ID。 如果其他搜尋服務身份使用該應用程式註冊,請重複此程序,並使用唯一的憑證名稱及該身份的租戶與主體 ID。 針對每個 Work IQ 知識來源使用對應的憑證 ID。
設定客戶端應用程式
若要設定可讓使用者登入並傳送擷取要求的應用程式:
在用戶端應用程式的 API 權限 頁面上,選取 新增權限>。
把你之前複製的 應用程式(客戶)ID 貼到搜尋框,然後選擇 Work IQ 應用程式註冊。
選擇 委派權限>access_as_user,然後選擇 新增權限。
請完成租戶用戶同意政策中所需的任何同意文件。 若需要管理員同意,請管理員選擇 授予[您的租戶]管理員同意。
客戶端應用程式現在可以請求使用者聲明來註冊 Work IQ 應用程式。 這個 access_as_user 權限並不賦予客戶端應用程式直接存取 Work IQ 的權限。
認證值
建立 Work IQ 知識來源時,請使用你 Microsoft Entra 應用程式設定中的以下entraAppAuthentication數值。 你提供的每個值都必須是一個 GUID。
| 房產 | Required | Value |
|---|---|---|
applicationId |
是的 | 你的 Work IQ 應用程式註冊的應用程式(客戶端)ID。 |
federatedCredentialId |
是的 | 你在應用程式上建立的聯邦憑證的物件 ID。 它不是憑證名稱,也不是搜尋服務主體 ID。 |
tenantId |
No | 應用程式註冊的(租戶)目錄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 是一個針對 Work IQ 知識來源的範例回應。
{
"name": "my-workiq-ks",
"kind": "workIQ",
"description": "A sample Work IQ knowledge source.",
"workIQParameters": {
"entraAppAuthentication": {
"applicationId": "11111111-1111-1111-1111-111111111111",
"federatedCredentialId": "22222222-2222-2222-2222-222222222222",
"tenantId": null
}
},
"encryptionKey": null
}
建立知識來源
執行以下程式碼建立 Work IQ 知識來源。
using Azure.Identity;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
using Azure.Search.Documents.Models;
Uri searchEndpoint =
new("https://<search-service-name>.search.windows.net");
var credential = new DefaultAzureCredential();
var indexClient = new SearchIndexClient(searchEndpoint, credential);
var entraAuthentication = new EntraAppAuthentication(
Guid.Parse("<application-client-id>"),
Guid.Parse("<federated-credential-id>"));
var knowledgeSource = new WorkIQKnowledgeSource(
"my-workiq-ks",
new WorkIQKnowledgeSourceParameters(entraAuthentication))
{
Description = "A sample Work IQ knowledge source."
};
KnowledgeSource createdSource =
await indexClient.CreateOrUpdateKnowledgeSourceAsync(knowledgeSource);
Console.WriteLine($"Created knowledge source '{createdSource.Name}'.");
from azure.identity import DefaultAzureCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
EntraAppAuthentication,
WorkIQKnowledgeSource,
WorkIQKnowledgeSourceParameters,
)
endpoint = "https://<search-service-name>.search.windows.net"
credential = DefaultAzureCredential()
knowledge_source = WorkIQKnowledgeSource(
name="my-workiq-ks",
description="A sample Work IQ knowledge source.",
work_iq_parameters=WorkIQKnowledgeSourceParameters(
entra_app_authentication=EntraAppAuthentication(
application_id="<application-client-id>",
federated_credential_id="<federated-credential-id>",
)
),
)
with SearchIndexClient(endpoint, credential) as index_client:
created_source = index_client.create_or_update_knowledge_source(
knowledge_source
)
print(f"Created knowledge source '{created_source.name}'.")
@search-endpoint = <search-endpoint> // Example: https://my-service.search.windows.net
@search-access-token = <search-access-token> // Run: az account get-access-token --scope https://search.azure.com/.default --query accessToken -o tsv
### Create a Work IQ knowledge source
PUT {{search-endpoint}}/knowledgesources/my-workiq-ks?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
Content-Type: application/json
Prefer: return=representation
{
"name": "my-workiq-ks",
"kind": "workIQ",
"description": "A sample Work IQ knowledge source.",
"workIQParameters": {
"entraAppAuthentication": {
"applicationId": "<application-client-id>",
"federatedCredentialId": "<federated-credential-id>"
}
}
}
參考資料:知識來源 - 建立或更新
指派至知識庫
如果你對知識來源感到滿意,就 把它加入知識庫。
查詢知識庫
在知識庫設定完成後, 呼叫擷取動作或 MCP 端點 來查詢 Work IQ 內容。 此知識來源具有獨特的查詢時間權限強制與回應特性。
Important
Work IQ 可能需要 40 到 60 秒甚至更久才會回應。 為避免逾時錯誤,請在擷取請求中將 maxRuntimeInSeconds 設為 120 或更高。
在查詢過程中強制執行權限
從 2026-08-01-preview API 版本開始,Work IQ 知識來源會透過客戶擁有的 Microsoft Entra 應用程式註冊,使用代表使用者 (OBO) 權杖流程。 除了驗證 Azure AI 搜尋服務 的取回請求外,您的客戶還必須為已登入的使用者提供應用程式受眾的使用者聲明。
你的客戶端應用程式必須登入使用者並取得使用者聲明。 你如何取得該主張,取決於應用程式的平台與語言。 使用 Microsoft 驗證程式庫 (MSAL) 和搭配代碼交換證明金鑰的授權碼流程 (PKCE),以要求確切的範圍 api://<application-client-id>/access_as_user。
在你寄出用戶聲明之前,請確認:
-
aud用於識別您的 Work IQ 應用程式註冊。 -
scp包含access_as_user。 -
oid並tid識別已登入的使用者與應用程式租戶。
請在同一個取用請求中傳送兩個憑證,如下範例所示。 使用Azure AI 搜尋服務令牌或API金鑰來進行服務認證。 將原始使用者斷言放入 x-ms-query-work-iq-source-authorization 標頭,而不是 x-ms-query-source-authorization。
using Azure.Identity;
using Azure.Search.Documents;
using Azure.Search.Documents.KnowledgeBases;
using Azure.Search.Documents.KnowledgeBases.Models;
Uri searchEndpoint =
new("https://<search-service-name>.search.windows.net");
string userAssertion = "<user-assertion>";
var credential = new DefaultAzureCredential();
var options = new SearchClientOptions();
options.Retry.NetworkTimeout = TimeSpan.FromSeconds(130);
var retrievalClient = new KnowledgeBaseRetrievalClient(
searchEndpoint,
"my-kb",
credential,
options);
var request = new KnowledgeBaseRetrievalRequest
{
IncludeActivity = true,
MaxRuntimeInSeconds = 120
};
request.Intents.Add(
new KnowledgeRetrievalSemanticIntent("Find my project status."));
request.KnowledgeSourceParams.Add(
new WorkIQKnowledgeSourceParams("my-workiq-ks")
{
IncludeReferences = true,
IncludeReferenceSourceData = true
});
var response = await retrievalClient.RetrieveAsync(
request,
querySourceAuthorization: null,
queryWorkIQSourceAuthorization: userAssertion);
Console.WriteLine(response.Value);
參考資料:KnowledgeBaseRetrievalClient, KnowledgeBaseRetrievalRequest
from azure.identity import DefaultAzureCredential
from azure.search.documents.knowledgebases import (
KnowledgeBaseRetrievalClient,
)
from azure.search.documents.knowledgebases.models import (
KnowledgeBaseRetrievalRequest,
KnowledgeRetrievalSemanticIntent,
WorkIQKnowledgeSourceParams,
)
endpoint = "https://<search-service-name>.search.windows.net"
user_assertion = "<user-assertion>"
credential = DefaultAzureCredential()
request = KnowledgeBaseRetrievalRequest(
intents=[
KnowledgeRetrievalSemanticIntent(
search="Find my project status."
)
],
knowledge_source_params=[
WorkIQKnowledgeSourceParams(
knowledge_source_name="my-workiq-ks",
include_references=True,
include_reference_source_data=True,
)
],
include_activity=True,
max_runtime_in_seconds=120,
)
with KnowledgeBaseRetrievalClient(
endpoint,
credential,
knowledge_base_name="my-kb",
) as retrieval_client:
response = retrieval_client.retrieve(
request,
query_work_iq_source_authorization=user_assertion,
timeout=130,
)
print(response)
參考資料:KnowledgeBaseRetrievalClient, KnowledgeBaseRetrievalRequest
@search-endpoint = <search-endpoint>
@search-access-token = <search-access-token>
@user-assertion = <user-assertion>
### Query a knowledge base with a Work IQ knowledge source
POST {{search-endpoint}}/knowledgebases/my-kb/retrieve?api-version=2026-08-01-preview
Authorization: Bearer {{search-access-token}}
x-ms-query-work-iq-source-authorization: {{user-assertion}}
Content-Type: application/json
{
"messages": [{
"role": "user",
"content": [{
"type": "text",
"text": "Find my project status."
}]
}],
"knowledgeSourceParams": [{
"knowledgeSourceName": "my-workiq-ks",
"kind": "workIQ",
"includeReferences": true,
"includeReferenceSourceData": true
}],
"includeActivity": true,
"maxRuntimeInSeconds": 120
}
參考資料:知識檢索 - 檢索
成功請求會返回 200 OK。 確認 activity 包含一個條目,其 type 為 workIQ,且其 knowledgeSourceName 與你的 Work IQ 知識來源相符。 也請確認該項目 references 包含 workIQ 條目。
下表列出常見的配置失敗案例。
| 現況 | 原因 |
|---|---|
| 400 | Work IQ 授權標頭缺失或格式錯誤、缺少必要的使用者聲明,或搜尋服務沒有支援的管理身份設定。 |
| 206 或 502 | Work IQ 來源失敗,原因在於代幣交換、同意、委派權限、聯邦憑證、下游授權,或是 Work IQ 請求失敗或逾時。檢查來源活動錯誤。 回應 206 表示另一個來源成功了。 回應 502 表示所有選定來源都失敗,或是某個必需來源失敗。 |
Work IQ 專屬回應欄位
Work IQ 知識來源會在 references 陣列中傳回結果,並在 activity 陣列中傳回查詢診斷資訊。 每個參考條目包含:
-
sourceData.parts[].text:來自 Work IQ 的基礎文字段落。 -
sourceData.parts[].data:Work IQ 引文資料。 引用部分具有媒體類型application/vnd.ms-workiq-reference。
以下範例展示了包含 Work IQ 知識來源參考及其對應活動記錄的檢索回應。 關於解讀檢索回應的更廣泛指引,請參見「檢視回應」。
Tip
若要接收參考的 sourceData,請在擷取要求的 includeReferenceSourceData 中,將知識來源項目上的 true 設定為 knowledgeSourceParams。
{
"response": [],
"activity": [
{
"type": "workIQ",
"id": 0,
"knowledgeSourceName": "my-workiq-ks",
"queryTime": "2026-08-01T19:25:23.683Z",
"count": 1,
"elapsedMs": 1137,
"workIQArguments": {
"search": "my query"
}
}
],
"references": [
{
"type": "workIQ",
"id": "83dd7d40",
"activitySource": 0,
"rerankerScore": 3.5,
"sourceData": {
"parts": [
{
"text": "Have your VPN username and password ready."
},
{
"data": {
"1-abc123": {
"targetLink": "https://contoso.sharepoint.com/doc.docx",
"isCitedInResponse": true,
"isSourceFiltered": false
}
},
"mediaType": "application/vnd.ms-workiq-reference"
}
]
}
}
]
}
刪除知識來源
在刪除知識來源之前,必須刪除所有引用該來源的知識庫,或更新知識庫定義以移除該參考。 對於產生索引與索引管線的知識來源,所有 產生的物件 也會被刪除。 不過,如果你用現有的索引建立知識來源,你的索引不會被刪除。
如果你嘗試刪除正在使用的知識來源,該動作會失敗,並回傳一份受影響的知識庫清單。
刪除知識來源:
取得你搜尋服務中所有知識庫的清單。
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}}參考資料:知識來源 - 刪除