Skip to content

Commit 904ea1f

Browse files
committed
sharepoint docs
1 parent f86da06 commit 904ea1f

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: 'How to use the Sharepoint tool'
3+
titleSuffix: Azure AI Foundry
4+
description: Find examples on how to ground agents with Sharepoint.
5+
services: cognitive-services
6+
manager: nitinme
7+
ms.service: azure-ai-agent-service
8+
ms.topic: how-to
9+
ms.date: 04/09/2025
10+
author: aahill
11+
ms.author: aahi
12+
ms.custom: azure-ai-agents-code
13+
zone_pivot_groups: selection-sharepoint
14+
---
15+
16+
# How to use the Sharepoint tool
17+
18+
Use this article to find step-by-step instructions and code samples for using the Sharepoint tool in Azure AI Foundry Agent Service.
19+
20+
## Step 1: Create a project client
21+
22+
Create a client object, which will contain the connection string for connecting to your AI project and other resources.
23+
24+
```python
25+
import os
26+
from azure.ai.projects import AIProjectClient
27+
from azure.identity import DefaultAzureCredential
28+
from azure.ai.projects.models import SharepointTool
29+
```
30+
31+
## Step 2: Create an Agent with the SharePoint tool enabled
32+
33+
To make the SharePoint tool available to your agent, use a connection to initialize the tool and attach it to the agent. You can find your connection in the **connected resources** section of your project in the Azure AI Foundry portal.
34+
35+
```python
36+
# Initialize Sharepoint tool with connection id
37+
sharepoint_connection = project_client.connections.get(
38+
connection_name="CONNECTION_NAME",
39+
)
40+
conn_id = sharepoint_connection.id
41+
print(conn_id)
42+
sharepoint = SharepointTool(connection_id=conn_id)
43+
44+
# Create agent with SharePoint tool and process assistant run
45+
with project_client:
46+
agent = project_client.agents.create_agent(
47+
model=os.environ["MODEL_NAME"],
48+
name="my-assistant",
49+
instructions="You are a helpful assistant",
50+
tools=sharepoint.definitions,
51+
headers={"x-ms-enable-preview": "true"},
52+
)
53+
print(f"Created agent, ID: {agent.id}")
54+
```
55+
56+
## Step 3: Create a thread
57+
58+
```python
59+
# Create thread for communication
60+
thread = project_client.agents.create_thread()
61+
print(f"Created thread, ID: {thread.id}")
62+
63+
# Create message to thread
64+
# Remember to update the message with your data
65+
message = project_client.agents.create_message(
66+
thread_id=thread.id,
67+
role="user",
68+
content="<ask questions specific to your SharePoint documents>",
69+
)
70+
print(f"Created message, ID: {message.id}")
71+
```
72+
73+
## Step 4: Create a run and check the output
74+
75+
Create a run and observe that the model uses the SharePoint tool to provide a response to the user's question.
76+
77+
```python
78+
# Create and process agent run in thread with tools
79+
run = project_client.agents.create_and_process_run(thread_id=thread.id, assistant_id=agent.id)
80+
print(f"Run finished with status: {run.status}")
81+
82+
if run.status == "failed":
83+
print(f"Run failed: {run.last_error}")
84+
85+
# Delete the assistant when done
86+
project_client.agents.delete_agent(agent.id)
87+
print("Deleted agent")
88+
89+
# Fetch and log all messages
90+
messages = project_client.agents.list_messages(thread_id=thread.id)
91+
print(f"Messages: {messages}")
92+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: 'How to use Microsoft SharePoint content with Azure AI Agent Service'
3+
titleSuffix: Azure OpenAI
4+
description: Learn how to ground Azure AI Agents using Microsoft SharePoint content.
5+
services: cognitive-services
6+
manager: nitinme
7+
ms.service: azure-ai-agent-service
8+
ms.topic: how-to
9+
ms.date: 05/01/2025
10+
author: aahill
11+
ms.author: aahi
12+
ms.custom: azure-ai-agents
13+
---
14+
# Use the Microsoft SharePoint tool
15+
16+
Integrate your Azure AI Agent with the **Microsoft Sharepoint** to chat with your private documents securely. You can connect to your SharePoint site, such as `contoso.sharepoint.com/sites/policies` to ground your Agents with that data. When a user sends a query, the agent will determine if SharePoint should be leveraged or not. If so, it will send a query using the SharePoint tool, which checks if the user has a Microsoft 365 copilot license and use managed identity to retrieve relevant documents they have access to. The scope of retrieval includes all supported documents in this SharePoint site. Lastly, the agent will generate responses based on retrieved information. With identity passthrough (On-Behalf-Of) authorization, this integration simplifies access to enterprise data in SharePoint while maintaining robust security, ensuring proper access control and enterprise-grade protection.
17+
18+
## Usage support
19+
20+
|Azure AI foundry support | Python SDK | C# SDK | JavaScript SDK | REST API |Basic agent setup | Standard agent setup |
21+
|---------|---------|---------|---------|---------|---------|---------|
22+
| ✔️ | ✔️ | - | - | ✔️ | ✔️ | ✔️ |
23+
24+
## Prerequisites
25+
1. Developers and end users have Microsoft 365 copilot license
26+
27+
1. Developers and end users have at least `AI Developer` RBAC role.
28+
29+
1. Developers and end users have at least `READ` access to the SharePoint site.
30+
31+
## Setup
32+
33+
> [!NOTE]
34+
> 1. Supported document types: text data in the following format: `.pdf`, `.docx`, `.ppt`, `.txt`, `.aspx`
35+
> 2. We recommend you start with SharePoint sites that have: a simple folder structure and a small number of short documents.
36+
37+
1. Create an Azure AI Agent by following the steps in the [quickstart](../../quickstart.md).
38+
39+
1. You can add the SharePoint tool to an agent programatically using the code examples listed at the top of this article, or the Azure AI Foundry portal. If you want to use the portal, in either the **Create and debug** or **Agent playground** screen for your agent, scroll down the setup pane on the right to knowledge. Then select **Add**.
40+
41+
:::image type="content" source="../../media/tools/knowledge-tools.png" alt-text="A screenshot showing the available tool categories in the Azure AI Foundry portal." lightbox="../../media/tools/knowledge-tools.png":::
42+
43+
1. Select **SharePoint** and follow the prompts to add the tool. You can only add one per agent.
44+
45+
1. Click to add a new connection. Once you have added a connection, you can directly select from existing list.
46+
1. To create a new connection, you need to find `site_url` in your SharePoint site. You can add either a SharePoint site or a SharePoint folder. For a SharePoint site, it will look like `https://microsoft.sharepoint.com/teams/<site_name>`. For a SharePoint folder, it will look like `https://microsoft.sharepoint.com/teams/<site_name>/Shared%20documents/<folder_name>`
47+
48+
1. Then, you can add it to your connection. Make sure you have selected the **is secret** option.
49+
50+
## Next steps
51+
52+
[See the full sample for SharePoint.](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_sharepoint.py)

articles/ai-services/agents/toc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ items:
9393
displayName: azure functions, functions
9494
- name: How to use Azure Functions
9595
href: how-to/tools/azure-functions-samples.md
96+
- name: Sharepoint
97+
items:
98+
- name: Overview
99+
href: how-to/tools/sharepoint.md
100+
displayName: sharepoint
101+
- name: How to use Sharepoint
102+
href: how-to/tools/sharepoint-samples.md
96103
- name: Enterprise features
97104
items:
98105
- name: Use your own resources

0 commit comments

Comments
 (0)