|
| 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: 06/05/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 | +## Create an agent |
| 21 | + |
| 22 | +Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api#api-call-information) to set the right values for the environment variables `AGENT_TOKEN`, `AZURE_AI_FOUNDRY_PROJECT_ENDPOINT` and `API_VERSION`. |
| 23 | + |
| 24 | +```bash |
| 25 | +curl --request POST \ |
| 26 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=$API_VERSION \ |
| 27 | + -H "Authorization: Bearer $AGENT_TOKEN" \ |
| 28 | + -H "Content-Type: application/json" \ |
| 29 | + -d '{ |
| 30 | + "instructions": "You are a helpful agent.", |
| 31 | + "name": "my-agent", |
| 32 | + "model": "gpt-4o", |
| 33 | + "tools": [ |
| 34 | + { |
| 35 | + "type": "sharepoint_grounding", |
| 36 | + "sharepoint_grounding": { |
| 37 | + "connections": [ |
| 38 | + { |
| 39 | + "connection_id": "/subscriptions/<sub-id>/resourceGroups/<your-rg-name>/providers/Microsoft.CognitiveServices/accounts/<your-ai-services-name>/projects/<your-project-name>/connections/<your-sharepoint-connection-name>" |
| 40 | + } |
| 41 | + ] |
| 42 | + } |
| 43 | + } |
| 44 | + ] |
| 45 | + }' |
| 46 | +``` |
| 47 | + |
| 48 | +## Create a thread |
| 49 | + |
| 50 | +```bash |
| 51 | +curl --request POST \ |
| 52 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=$API_VERSION \ |
| 53 | + -H "Authorization: Bearer $AGENT_TOKEN" \ |
| 54 | + -H "Content-Type: application/json" \ |
| 55 | + -d '' |
| 56 | +``` |
| 57 | + |
| 58 | +### Add a user question to the thread |
| 59 | + |
| 60 | +```bash |
| 61 | +curl --request POST \ |
| 62 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=$API_VERSION \ |
| 63 | + -H "Authorization: Bearer $AGENT_TOKEN" \ |
| 64 | + -H "Content-Type: application/json" \ |
| 65 | + -d '{ |
| 66 | + "role": "user", |
| 67 | + "content": "What is the weather in Seattle?" |
| 68 | + }' |
| 69 | +``` |
| 70 | + |
| 71 | +## Run the thread |
| 72 | + |
| 73 | +```bash |
| 74 | +curl --request POST \ |
| 75 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=$API_VERSION \ |
| 76 | + -H "Authorization: Bearer $AGENT_TOKEN" \ |
| 77 | + -H "Content-Type: application/json" \ |
| 78 | + -d '{ |
| 79 | + "assistant_id": "asst_abc123", |
| 80 | + }' |
| 81 | +``` |
| 82 | + |
| 83 | +## Retrieve the status of the run |
| 84 | + |
| 85 | +```bash |
| 86 | +curl --request GET \ |
| 87 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=$API_VERSION \ |
| 88 | + -H "Authorization: Bearer $AGENT_TOKEN" |
| 89 | +``` |
| 90 | + |
| 91 | +## Retrieve the agent response |
| 92 | + |
| 93 | +```bash |
| 94 | +curl --request GET \ |
| 95 | + --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=$API_VERSION \ |
| 96 | + -H "Authorization: Bearer $AGENT_TOKEN" |
| 97 | +``` |
0 commit comments