重要
この記事でマークされている項目 (プレビュー) は、現在パブリック プレビュー段階です。 このプレビューはサービス レベル アグリーメントなしで提供されており、運用環境のワークロードにはお勧めしません。 特定の機能がサポートされていないか、機能が制限されている可能性があります。 詳細については、「Microsoft Azure プレビューの使用条件を参照してください。
メモ
- この記事では、Foundry Agent Service のMicrosoft SharePoint ツールについて説明します。 SharePoint サイトの使用と展開の詳細については、SharePoint ドキュメントを参照してください。
- ツールの使用を最適化する方法については、 ベスト プラクティス を参照してください。
Microsoft Foundry Agent ServiceでのSharePointの基盤として、SharePointサイトやフォルダー(例:contoso.sharepoint.com/sites/policies)からコンテンツを取得するには、SharePointツール(プレビュー)を使用します。 ユーザーが質問をすると、エージェントは SharePoint ツールを呼び出して、ユーザーがアクセスできるドキュメントから関連するテキストを取得できます。 エージェントは、その取得したコンテンツに基づいて応答を生成します。
この統合では ID パススルー (On-Behalf-Of) が使用されるため、SharePointアクセス許可はすべての要求に引き続き適用されます。 基になる Microsoft 365 Copilot 取得 API の統合の詳細については、「しくみを参照してください。
重要
開始する前に:SharePoint ツールでは、ユーザー ID 認証 (アプリ専用/サービス プリンシパルなし) が必要です。SharePoint サイトと Foundry エージェントは同じテナントに存在する必要があり、エージェントごとに 1 つのSharePoint ツールのみがサポートされます。 エージェントがMicrosoft Teamsに発行されると、ツールは機能しません。 完全な一覧については 、「制限事項 」を参照してください。
前提 条件
対象ライセンスまたは従量課金制モデル:
- 開発者とエンド ユーザーは、Microsoft 365 Copilot 取得 API で必要なMicrosoft 365 Copilot ライセンスを持っています。
- 開発者とエンド ユーザーがMicrosoft 365 Copilotライセンスを持っていない場合は、従年課金制モデルを有効にすることができます。
開発者とエンド ユーザーには、Foundry プロジェクトに少なくとも
Foundry UserRBAC ロールが割り当てられます。 Azureロールベースのアクセス制御の詳細については、Foundry のAzureロールベースのアクセス制御に関するページを参照してください。 重要
Foundry RBAC ロールの名前が最近変更されました。 Foundry User, Foundry Owner, Foundry Account Owner、および Foundry Project Manager は、以前は、AZURE AI ユーザー、Azure AI 所有者、Azure AI アカウント所有者、および AZURE AI Project Manager という名前でした。 名前の変更がロールアウトされている間、以前の名前が表示される場合があります。ロール ID とコア アクセス許可は、名前の変更によって変更されません。
開発者とエンド ユーザーは、SharePoint サイトに少なくとも
READアクセスできます。SharePoint テナントと Foundry プロジェクトが同じMicrosoft Entra テナントにあることを確認します。 テナント間トークン交換はサポートされていません。
必要な SDK パッケージをインストールします。
-
Python:
pip install "azure-ai-projects>=2.0.0" -
C#:
Azure.AI.ProjectsNuGet パッケージをインストールします -
TypeScript/JavaScript:
npm install @azure/ai-projects -
Java:
pom.xmlに最新のcom.azure:azure-ai-agents依存関係を追加する
-
Python:
サンプルで使用する環境変数を構成します。
-
FOUNDRY_PROJECT_ENDPOINT: Foundry プロジェクト のエンドポイント URL -
FOUNDRY_MODEL_DEPLOYMENT_NAME: モデル のデプロイ名 (例:gpt-4) -
SHAREPOINT_PROJECT_CONNECTION_ID:/subscriptions/{{subscriptionID}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.CognitiveServices/accounts/{{foundryAccountName}}/projects/{{foundryProjectName}}/connections/{{foundryConnectionName}}形式のSharePoint接続 ID - REST サンプルの場合:
AGENT_TOKEN
-
その他の認証設定の詳細については、 クイック スタート を参照してください。
SharePoint接続と委任されたユーザーを設定する
SharePoint ツールでは、委任されたユーザー認証が使用されます。 サインインしているユーザーの ID でエージェントを実行SharePoint、そのユーザーのサイト、フォルダー、ドキュメントのアクセス許可を適用できます。 アプリのみの認証とサービス プリンシパル認証はサポートされていません。
メモ
簡単なフォルダー構造と少数の短いドキュメントを持つSharePoint サイトから始めます。
- SharePointを選択し、指示に従ってツールを追加します。 エージェントごとに追加できるSharePoint ツールは 1 つだけです。
- SharePoint接続を追加します。 完全な接続ワークフローについては、「 新しい接続をプロジェクトに追加する」を参照してください。
- SharePoint接続構成で、サイト URL またはフォルダー URL を入力します。
- サイト URL:
https://<company>.sharepoint.com/sites/<site_name> - フォルダー URL:
https://<company>.sharepoint.com/sites/<site_name>/Shared%20documents/<folder_name>
サイトまたはフォルダーの URL は、次のいずれかの形式で使用します。 サポートされていないパスまたはクエリ文字列の値を含めることができる完全なブラウザー アドレスをコピーしないでください。
- 接続を保存し、その接続 ID をコピーします。
- 接続 ID を
SHAREPOINT_PROJECT_CONNECTION_IDとして設定します。 - 構成されたSharePoint スコープに少なくとも
READアクセスできるユーザーとしてサインインし、そのユーザーの委任された ID でエージェントを実行します。
アクセス許可で絞り込まれた取得を確認する
エージェントをユーザーが使用できるようにする前に、正常な取得と拒否された取得の両方を確認します。
- 1 人のテスト ユーザーが読み取り可能で、2 番目のテスト ユーザーが読み取ることができない、構成されたスコープ内のドキュメントを選択します。
- アクセス権を持つユーザーとしてサインインし、そのドキュメントに回答がある質問をして、応答に予想される情報とドキュメントへの引用が含まれていることを確認します。
- アクセス権を持たないユーザーとしてサインインし、同じ質問をします。 制限付きドキュメントからの情報や引用が応答に含まれていないことを確認します。
委任されたユーザー認証を使用して両方のチェックを実行します。 最初のユーザーからの応答が取得を確認します。2 番目のユーザーの異なる結果は、SharePointアクセス許可のトリミングが適用されていることを確認します。
使用サポート
次の表に、SDK とセットアップのサポートを示します。
| Microsoft Foundry のサポート | Python SDK | C# SDK | JavaScript SDK | Java SDK | REST API | 基本的なエージェントのセットアップ | 標準エージェントのセットアップ |
|---|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
パラメーター
SharePoint ツールは、プロジェクト接続を使用して、どのSharePointサイトまたはフォルダーから取得できるかを決定します。
| パラメーター | 必須 | ノート |
|---|---|---|
type |
はい |
sharepoint_grounding_previewを使用します。 |
sharepoint_grounding_preview.project_connections[].project_connection_id |
はい |
SHAREPOINT_PROJECT_CONNECTION_IDの値を使用します。 |
プロジェクトのSharePoint接続を作成する必要がある場合は、「プロジェクトに新しい接続を追加するを参照してください。
SharePoint ツールを使用してエージェントを作成する
SDK サンプルでは、 DefaultAzureCredentialを使用します。 ローカルで実行する場合、この資格情報は、サインインしているユーザーの ID ( az loginによって確立された ID など) に解決される必要があります。 ローカル資格情報チェーンからマネージド ID とサービス プリンシパルの資格情報を除外します。 運用アプリケーションでは、現在のユーザーの委任された ID で各要求を認証し、代理フローを使用します。 アプリケーションのマネージド ID またはサービス プリンシパルを使用して SharePoint ツールの呼び出しを実行しないでください。
次のサンプルは、SharePoint ツールを使用して、SharePoint サイトのコンテンツに基づいた応答を生成するエージェントの作成方法を示します。 Azure AI Projects SDK を使用してサーバー側プロンプト エージェントを作成する場合は Prompt Agents を選択します。エージェント フレームワーク を使用してエフェメラルなインプロセス エージェントを作成するには、FoundryChatClient を選択します。
エージェントに指示を促す
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
PromptAgentDefinition,
SharepointPreviewTool,
SharepointGroundingToolParameters,
ToolProjectConnection,
)
# Format: "https://resource_name.ai.azure.com/api/projects/project_name"
PROJECT_ENDPOINT = "your_project_endpoint"
SHAREPOINT_CONNECTION_NAME = "my-sharepoint-connection"
# Create clients to call Foundry API
project = AIProjectClient(
endpoint=PROJECT_ENDPOINT,
credential=DefaultAzureCredential(),
)
openai = project.get_openai_client()
# Get connection ID from connection name
sharepoint_connection = project.connections.get(
SHAREPOINT_CONNECTION_NAME,
)
# Configure SharePoint tool with the project connection
sharepoint_tool= SharepointPreviewTool(
sharepoint_grounding_preview=SharepointGroundingToolParameters(
project_connections=[
ToolProjectConnection(project_connection_id=sharepoint_connection.id)
]
)
)
agent = project.agents.create_version(
agent_name="MyAgent",
definition=PromptAgentDefinition(
model="gpt-4.1-mini",
instructions="""You are a helpful agent that can use SharePoint tools to assist users.
Use the available SharePoint tools to answer questions and perform tasks.""",
tools=[sharepoint_tool],
),
)
print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})")
# Send initial request that will trigger the SharePoint tool
stream_response = openai.responses.create(
stream=True,
tool_choice="required",
input="Please summarize the last meeting notes stored in SharePoint.",
extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}},
)
for event in stream_response:
if event.type == "response.created":
print(f"Follow-up response created with ID: {event.response.id}")
elif event.type == "response.output_text.delta":
print(f"Delta: {event.delta}")
elif event.type == "response.output_text.done":
print(f"\nFollow-up response done!")
elif event.type == "response.output_item.done":
if event.item.type == "message":
item = event.item
if item.content[-1].type == "output_text":
text_content = item.content[-1]
for annotation in text_content.annotations:
if annotation.type == "url_citation":
print(
f"URL Citation: {annotation.url}, "
f"Start index: {annotation.start_index}, "
f"End index: {annotation.end_index}"
)
elif event.type == "response.completed":
print(f"\nFollow-up completed!")
print(f"Full response: {event.response.output_text}")
予期される出力
このコードを実行すると、次のような出力が表示されます。
Agent created (id: asst_abc123, name: MyAgent, version: 1)
Sending request to SharePoint agent with streaming...
Follow-up response created with ID: resp_xyz789
Delta: Based
Delta: on
Delta: the
Delta: meeting
Delta: notes
...
URL Citation: https://contoso.sharepoint.com/sites/policies/Documents/meeting-notes.docx, Start index: 0, End index: 245
Follow-up response done!
Follow-up completed!
Full response: Based on the meeting notes from your SharePoint site, the last meeting covered the following topics: project timeline updates, budget review, and next quarter planning.
ホスト型エージェント
このサンプルでは、Microsoft Agent Framework から FoundryChatClient を使用し、get_sharepoint_tool() を呼び出して、SharePointの接地接続を接続します。
AIProjectClientを使用して接続名を接続 ID に解決し、メッセージ注釈を反復処理して URL 引用を出力します。
pip install agent-framework-foundry aiohttpでパッケージをインストールし、FOUNDRY_PROJECT_ENDPOINTとFOUNDRY_MODEL環境変数を設定し、az loginでサインインします。
import asyncio
import os
from agent_framework import Agent
from agent_framework.foundry import FoundryChatClient
from azure.ai.projects import AIProjectClient
from azure.identity import AzureCliCredential
SHAREPOINT_CONNECTION_NAME = "my-sharepoint-connection"
async def main() -> None:
credential = AzureCliCredential()
project = AIProjectClient(
endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
credential=credential,
)
sharepoint_connection_id = project.connections.get(SHAREPOINT_CONNECTION_NAME).id
agent = Agent(
client=FoundryChatClient(credential=credential),
instructions="You are a helpful agent. Use the SharePoint tool to answer questions.",
tools=[FoundryChatClient.get_sharepoint_tool(connection_id=sharepoint_connection_id)],
)
result = await agent.run("Please summarize the last meeting notes stored in SharePoint.")
print(f"Agent: {result.text}")
for message in result.messages:
for content in message.contents:
for annotation in getattr(content, "annotations", None) or []:
url = getattr(annotation, "url", None)
if url:
title = getattr(annotation, "title", None) or ""
print(f"URL Citation: [{title}]({url})")
if __name__ == "__main__":
asyncio.run(main())
予期される出力
応答テキストは、SharePoint グラウンド ツールから返された URL 引用と共に出力されます。
Agent: Based on the meeting notes from your SharePoint site ...
URL Citation: [Meeting notes](https://contoso.sharepoint.com/sites/policies/Documents/meeting-notes.docx)
Agent Framework Foundry ツール ファクトリの詳細については、 Foundry プロバイダーのサンプルを参照してください。
次のサンプルは、SharePoint ツールを使用して、SharePoint サイトのコンテンツに基づいた応答を生成するエージェントの作成方法を示します。 この例では、わかりやすくするために同期メソッドを使用します。 非同期バージョンについては、.NET GitHub リポジトリのAzure SDKのSharePoint エージェントのサンプル ドキュメントを参照してください。
エージェントがSharePointにアクセスできるようにするには、SharepointPreviewTool を使用します。
Prompt Agents を選択して、Azure AI Projects SDK を使用してサーバー側プロンプト エージェントを作成するか、Hosted Agents を使用して、Microsoft Agent Framework を使用してエフェメラルなインプロセス エージェントを構築します。
エージェントに指示を促す
using System;
using Azure.AI.Projects;
using Azure.AI.Extensions.OpenAI;
using Azure.Identity;
// Format: "https://resource_name.ai.azure.com/api/projects/project_name"
var projectEndpoint = "your_project_endpoint";
var sharepointConnectionName = "my-sharepoint-connection";
// Create project client to call Foundry API
AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential());
// Get connection ID from connection name
AIProjectConnection sharepointConnection = projectClient.Connections.GetConnection(connectionName: sharepointConnectionName);
// Use the SharePoint connection ID to initialize the SharePointGroundingToolOptions,
// which will be used to create SharepointPreviewTool. Use this tool to create an Agent.
SharePointGroundingToolOptions sharepointToolOption = new()
{
ProjectConnections = { new ToolProjectConnection(projectConnectionId: sharepointConnection.Id) }
};
DeclarativeAgentDefinition agentDefinition = new(model: "gpt-4.1-mini")
{
Instructions = "You are a helpful assistant.",
Tools = { new SharepointPreviewTool(sharepointToolOption), }
};
AgentVersion agentVersion = projectClient.AgentAdministrationClient.CreateAgentVersion(
agentName: "myAgent",
options: new(agentDefinition));
// Create the response and make sure we are always using tool.
ProjectResponsesClient responseClient = projectClient.ProjectOpenAIClient.GetProjectResponsesClientForAgent(agentVersion.Name);
CreateResponseOptions responseOptions = new()
{
ToolChoice = ResponseToolChoice.CreateRequiredChoice(),
InputItems = { ResponseItem.CreateUserMessageItem("What is Contoso whistleblower policy") }
};
ResponseResult response = responseClient.CreateResponse(options: responseOptions);
// SharePoint tool can create the reference to the page, grounding the data.
// Create the GetFormattedAnnotation method to get the URI annotation.
string annotation = "";
foreach (ResponseItem item in response.OutputItems)
{
if (item is MessageResponseItem messageItem)
{
foreach (ResponseContentPart content in messageItem.Content)
{
foreach (ResponseMessageAnnotation messageAnnotation in content.OutputTextAnnotations)
{
if (messageAnnotation is UriCitationMessageAnnotation uriAnnotation)
{
annotation = $" [{uriAnnotation.Title}]({uriAnnotation.Uri})";
}
}
}
}
}
// Print the Agent output and add the annotation at the end.
Console.WriteLine($"Response status: {response.Status}");
Console.WriteLine($"{response.GetOutputText()}{annotation}");
// After the sample is completed, delete the Agent we have created.
projectClient.AgentAdministrationClient.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version);
予期される出力
このコードを実行すると、次のような出力が表示されます。
The Contoso whistleblower policy outlines procedures for reporting unethical behavior confidentially. Employees can submit concerns through the ethics hotline or online portal. [Whistleblower Policy](https://contoso.sharepoint.com/sites/policies/Documents/whistleblower-policy.pdf)
出力には、ソース ドキュメントへの引用リンクを含む、SharePointコンテンツに基づいてエージェントの応答が含まれます。
ホスト型エージェント
このサンプルでは、Microsoft Agent Framework を使用し、AsAIAgent(...) の AIProjectClient と共に、FoundryAITool.CreateSharepointTool(...) で Microsoft.Agents.AI.Foundry を呼び出します。
Microsoft.Agents.AI.Foundry パッケージと Azure.AI.Projects パッケージをインストールし、AZURE_AI_PROJECT_ENDPOINT、AZURE_AI_MODEL_DEPLOYMENT_NAME、および SHAREPOINT_PROJECT_CONNECTION_ID 環境変数を設定し、az login でサインインします。
using Azure.AI.Projects;
using Azure.AI.Projects.Agents;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Foundry;
string sharepointConnectionId = Environment.GetEnvironmentVariable("SHAREPOINT_PROJECT_CONNECTION_ID")
?? throw new InvalidOperationException("SHAREPOINT_PROJECT_CONNECTION_ID is not set.");
string endpoint = Environment.GetEnvironmentVariable("AZURE_AI_PROJECT_ENDPOINT")
?? throw new InvalidOperationException("AZURE_AI_PROJECT_ENDPOINT is not set.");
string deploymentName = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-5-mini";
const string AgentInstructions = """
You are a helpful agent that can use SharePoint tools to assist users.
Use the available SharePoint tools to answer questions and perform tasks.
""";
var sharepointOptions = new SharePointGroundingToolOptions();
sharepointOptions.ProjectConnections.Add(new ToolProjectConnection(sharepointConnectionId));
AIProjectClient aiProjectClient = new(new Uri(endpoint), new DefaultAzureCredential());
AIAgent agent = aiProjectClient.AsAIAgent(deploymentName,
instructions: AgentInstructions,
name: "SharePointAgent",
tools: [FoundryAITool.CreateSharepointTool(sharepointOptions)]);
AgentResponse response = await agent.RunAsync("List the documents available in SharePoint");
Console.WriteLine($"Response: {response.Text}");
// Print any URL citations returned by the SharePoint grounding tool.
foreach (AIAnnotation annotation in response.Messages
.SelectMany(m => m.Contents)
.SelectMany(c => c.Annotations ?? []))
{
if (annotation.RawRepresentation is UriCitationMessageAnnotation urlCitation)
{
Console.WriteLine($"URL Citation: [{urlCitation.Title}]({urlCitation.Uri})");
}
}
予期される出力
応答テキストは、SharePoint ツールから返された URL 引用と共に出力されます。
Response: Based on the documents in SharePoint ...
URL Citation: [Whistleblower Policy](https://contoso.sharepoint.com/sites/policies/Documents/whistleblower-policy.pdf)
完全なサンプルについては、 Agent_Step19_SharePointを参照してください。
SharePointでエージェントを使用するためのサンプル
アクセス トークンを取得します。
export AGENT_TOKEN=$(az account get-access-token --scope "https://ai.azure.com/.default" --query accessToken -o tsv)
次の例では、SharePoint ツールを使用して、SharePoint サイトのコンテンツに対する応答を処理するエージェントを作成する方法を示します。
curl --request POST \
--url "$FOUNDRY_PROJECT_ENDPOINT/openai/v1/responses" \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "'$FOUNDRY_MODEL_DEPLOYMENT_NAME'",
"input": "Please summarize the last meeting notes stored in SharePoint.",
"tool_choice": "required",
"tools": [
{
"type": "sharepoint_grounding_preview",
"sharepoint_grounding_preview": {
"project_connections": [
{
"project_connection_id": "'$SHAREPOINT_PROJECT_CONNECTION_ID'"
}
]
}
}
]
}'
予期される出力
API は、エージェントの回答と引用情報を含む JSON 応答を返します。
{
"id": "resp_abc123xyz",
"object": "response",
"created_at": 1702345678,
"status": "completed",
"output": [
{
"id": "msg_abc123xyz",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "Based on the meeting notes...",
"annotations": [
{
"type": "url_citation",
"url": "https://contoso.sharepoint.com/sites/policies/Documents/meeting-notes.docx",
"start_index": 0,
"end_index": 245
}
]
}
]
}
]
}
このサンプルでは、SharePoint機能を備えた AI エージェントを作成する方法を示します。 エージェントは、SharePointコンテンツを検索し、SharePointサイトからの関連情報を含む応答を提供できます。 JavaScript バージョンについては、javaScript GitHub リポジトリのAzure SDKのSharePoint エージェントのサンプル ドキュメントを参照してください。
import { DefaultAzureCredential } from "@azure/identity";
import { AIProjectClient } from "@azure/ai-projects";
// Format: "https://resource_name.ai.azure.com/api/projects/project_name"
const PROJECT_ENDPOINT = "your_project_endpoint";
const SHAREPOINT_CONNECTION_NAME = "my-sharepoint-connection";
export async function main(): Promise<void> {
// Create clients to call Foundry API
const project = new AIProjectClient(PROJECT_ENDPOINT, new DefaultAzureCredential());
const openai = project.getOpenAIClient();
// Get connection ID from connection name
const sharepointConnection = await project.connections.get(SHAREPOINT_CONNECTION_NAME);
// Create agent with SharePoint tool
const agent = await project.agents.createVersion("MyAgent", {
kind: "prompt",
model: "gpt-4.1-mini",
instructions:
"You are a helpful agent that can use SharePoint tools to assist users. Use the available SharePoint tools to answer questions and perform tasks.",
// Define SharePoint tool that searches SharePoint content
tools: [
{
type: "sharepoint_grounding_preview",
sharepoint_grounding_preview: {
project_connections: [
{
project_connection_id: sharepointConnection.id,
},
],
},
},
],
});
console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
// Send initial request that will trigger the SharePoint tool
const streamResponse = await openai.responses.create(
{
input: "Please summarize the last meeting notes stored in SharePoint.",
stream: true,
},
{
body: {
agent_reference: { name: agent.name, type: "agent_reference" },
tool_choice: "required",
},
},
);
// Process the streaming response
for await (const event of streamResponse) {
if (event.type === "response.created") {
console.log(`Follow-up response created with ID: ${event.response.id}`);
} else if (event.type === "response.output_text.delta") {
process.stdout.write(event.delta);
} else if (event.type === "response.output_text.done") {
console.log("\n\nFollow-up response done!");
} else if (event.type === "response.output_item.done") {
if (event.item.type === "message") {
const item = event.item;
if (item.content && item.content.length > 0) {
const lastContent = item.content[item.content.length - 1];
if (lastContent.type === "output_text" && lastContent.annotations) {
for (const annotation of lastContent.annotations) {
if (annotation.type === "url_citation") {
console.log(
`URL Citation: ${annotation.url}, Start index: ${annotation.start_index}, End index: ${annotation.end_index}`,
);
}
}
}
}
}
} else if (event.type === "response.completed") {
console.log("\nFollow-up completed!");
}
}
// Clean up resources
await project.agents.deleteVersion(agent.name, agent.version);
}
main().catch((err) => {
console.error("The sample encountered an error:", err);
});
予期される出力
このコードを実行すると、次のような出力が表示されます。
Creating agent with SharePoint tool...
Agent created (id: asst_abc123, name: MyAgent, version: 1)
Sending request to SharePoint agent with streaming...
Follow-up response created with ID: resp_xyz789
Based on the meeting notes from your SharePoint site, the last meeting covered the following topics: project timeline updates, budget review, and next quarter planning.
Follow-up response done!
URL Citation: https://contoso.sharepoint.com/sites/policies/Documents/meeting-notes.docx, Start index: 0, End index: 245
Follow-up completed!
Cleaning up resources...
Agent deleted
SharePoint agent sample completed!
JavaエージェントでSharePointグラウンディングを利用する
依存関係を pom.xmlに追加します。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-agents</artifactId>
<version>2.4.0</version>
</dependency>
SharePoint に基づいてエージェントを作成する
import com.azure.ai.agents.AgentsClient;
import com.azure.ai.agents.AgentsClientBuilder;
import com.azure.ai.agents.ResponsesClient;
import com.azure.ai.agents.models.*;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.openai.models.responses.Response;
import com.openai.models.responses.ResponseCreateParams;
import java.util.Arrays;
import java.util.Collections;
public class SharePointGroundingExample {
public static void main(String[] args) {
// Format: "https://resource_name.ai.azure.com/api/projects/project_name"
String projectEndpoint = "your_project_endpoint";
String sharepointConnectionId = "your_sharepoint_connection_id";
AgentsClientBuilder builder = new AgentsClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.endpoint(projectEndpoint);
AgentsClient agentsClient = builder.buildAgentsClient();
ResponsesClient responsesClient = builder.buildResponsesClient();
// Create SharePoint grounding tool with connection configuration
SharepointPreviewTool sharepointTool = new SharepointPreviewTool(
new SharepointGroundingToolParameters()
.setProjectConnections(Arrays.asList(
new ToolProjectConnection(sharepointConnectionId)
))
);
// Create agent with SharePoint tool
PromptAgentDefinition agentDefinition = new PromptAgentDefinition("gpt-4.1-mini")
.setInstructions("You are a helpful assistant that can search through SharePoint documents.")
.setTools(Collections.singletonList(sharepointTool));
AgentVersionDetails agent = agentsClient.createAgentVersion("sharepoint-agent", agentDefinition);
System.out.printf("Agent created: %s (version %s)%n", agent.getName(), agent.getVersion());
// Create a response
AgentReference agentReference = new AgentReference(agent.getName())
.setVersion(agent.getVersion());
Response response = responsesClient.createAzureResponse(
new AzureCreateResponseOptions().setAgentReference(agentReference),
ResponseCreateParams.builder()
.input("Find the latest project documentation in SharePoint"));
System.out.println("Response: " + response.output());
// Clean up
agentsClient.deleteAgentVersion(agent.getName(), agent.getVersion());
}
}
制限
- SharePoint ツールでは、ユーザー ID 認証のみがサポートされます。 アプリ専用 (サービス プリンシパル) 認証はサポートされていません。
- SharePoint サイトと Microsoft Foundry エージェントは、同じテナント内にある必要があります。
- エージェントごとに追加できるSharePoint ツールは 1 つだけです。
- 基になるMicrosoft 365 Copilot 取得 API は、抽出されたテキストを返します。 画像やグラフを含む非テキスト コンテンツからの取得はサポートされていません。
- セマンティックおよびハイブリッド取得の場合、Microsoft 365 Copilot取得 API では、
.doc、.docx、.pptx、.pdf、.aspx、および.oneファイルの種類がサポートされます。 詳細については、Microsoft 365 Copilot API を参照してください。 - 基になる取得 API は最大 25 個の結果を返し、1 時間あたりユーザーあたり 200 件の要求を許可します。 クエリ文字列には、最大 1,500 文字を含めることができます。
しくみ
SharePoint ツールを使用すると、AI エージェントと、SharePointに格納されているビジネス ドキュメント間のシームレスな統合が可能になります。 この機能は、Microsoft 365 Copilot API によって強化されます。 SharePointドキュメントを基盤にするには、接続するサイトまたはフォルダーを指定してください。 SharePoint ツールは、組み込みのインデックス作成機能を活用して、インテリジェントなインデックス作成、クエリ処理、コンテンツ チャンクなど、検索と取得のエクスペリエンスを強化します。
Foundry での委任されたアクセスと ID パススルーの詳細については、「Agent identity concepts in Microsoft Foundryを参照してください。
この機能は、開発者にSharePointコンテンツのエクスポート、カスタム セマンティック インデックスの作成、ガバナンス コントロールの管理、更新ロジックの構成を要求する代わりに、取得パイプライン全体を自動化します。 ドキュメントのインデックスを動的に作成し、コンテンツを意味のあるチャンクに分割し、高度なクエリ処理を適用して最も関連性の高い情報を表示します。 この機能は、Microsoft 365 Copilotを駆動するのと同じエンタープライズ向けの取得スタックを使用することで、AIエージェントの応答が最新かつコンテキストに関連するコンテンツに基づくようにします。
お客様は、柔軟なドキュメント レベルのアクセス制御を使用してドキュメントにアクセスし、作成し、共有するために、SharePointのデータ セキュリティに依存しています。 ID パススルー (On-Behalf-Of) 認証などのエンタープライズ機能により、適切なアクセス制御が保証されます。 エンド ユーザーは、アクセス許可SharePointドキュメントから生成された応答を受け取ります。 Foundry Agent Service は、OBO 認証を使用してエンド ユーザーの ID を使用して、関連するSharePointドキュメントを承認および取得し、特定のエンド ユーザーに合わせた応答を生成します。
トラブルシューティング
| 問題 | 原因 | 解決方法 |
|---|---|---|
AuthenticationError: AppOnly OBO tokens not supported by target service |
ユーザー ID の代わりにアプリケーション ID を使用する | SharePoint ツールには、ユーザー ID (ID パススルー) が必要です。 アプリケーションのみの認証は使用しないでください。 |
Forbidden: Authorization Failed - User does not have valid license |
Microsoft 365 Copilotライセンスまたは従量課金制モデルがない | Microsoft 365 Copilot ライセンスをユーザーに割り当てるか、従量課金制を有効にします。 前提条件を参照してください。 |
| 401 または認証エラー | テナント間アクセスの試行 | Foundry と Microsoft 365 のユーザーが同じテナント内にいます。 |
| ツールから結果が返されない | ユーザーがSharePointコンテンツへのアクセス権を持たない | クエリ対象のSharePoint サイトとドキュメントに対する読み取りアクセス権がユーザーに付与されていることを確認します。 |
| 応答時間が遅い | 大規模なドキュメント検索範囲 | 特定のサイトまたはライブラリを指定して、検索範囲を絞り込みます。 より具体的な検索クエリの使用を検討してください。 |
| 不完全なドキュメントの取得 | インデックスが作成されていないコンテンツ | SharePointコンテンツがMicrosoft Searchによってインデックス付けされていることを確認します。 最近追加されたコンテンツには、インデックスを作成する時間が必要になる場合があります。 |
Resource not found エラー |
無効なサイトまたはライブラリのパス | SharePoint サイトの URL とライブラリ のパスが正しく、ユーザーがアクセス可能であることを確認します。 |
| 一貫性のない検索結果 | セマンティック インデックス同期の遅延 | セマンティック インデックスが同期されるまで待ちます。コンテンツの大きな変更が反映されるまでに時間がかかる場合があります。 Microsoft 365 Copilotに関する詳細については、セマンティックインデックス作成を参照してください。 |