You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-foundry/agents/how-to/tools/azure-ai-search-samples.md
+70-39Lines changed: 70 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,52 @@
1
1
---
2
2
title: 'How to use Azure AI Search in Azure AI Foundry Agent Service'
3
3
titleSuffix: Azure AI Foundry
4
-
description: Learn how to ground Azure AI Agents using Azure AI Search.
4
+
description: Learn how to ground Azure AI Agents with content indexed in Azure AI Search.
5
5
services: cognitive-services
6
6
manager: nitinme
7
7
ms.service: azure-ai-agent-service
8
8
ms.topic: how-to
9
-
ms.date: 07/11/2025
10
-
author: aahill
11
-
ms.author: aahi
9
+
ms.date: 09/11/2025
10
+
author: haileytap
11
+
ms.author: haileytapia
12
+
ms.reviewer: aahi
12
13
ms.custom: azure-ai-agents
13
14
zone_pivot_groups: selection-azure-ai-search
14
15
---
15
16
16
-
# How to use an existing Azure AI Search index with the Azure AI Search tool
17
+
# How to use an existing index with the Azure AI Search tool
17
18
18
-
This article shows how to use an existing Azure AI Search index with the Azure AI Search tool.
19
+
This article explains how to use an existing search index with the [Azure AI Search](/azure/search/search-what-is-azure-search) tool.
19
20
20
21
## Prerequisites
21
-
Complete the [Azure AI Search tool setup](../../how-to/tools/azure-ai-search.md?pivot=overview-azure-ai-search).
22
+
23
+
+ Completion of the [Azure AI Search tool setup](../../how-to/tools/azure-ai-search.md?pivot=overview-azure-ai-search).
22
24
23
25
:::zone pivot="portal"
24
26
25
-
1. Go to the Azure AI Foundry portal, and navigate to the **Agents** screen for your agent, scroll down the **Setup** pane on the right to **knowledge**. Then select **Add**.
27
+
## Add the Azure AI Search tool to an agent
28
+
29
+
1. Sign in to the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs) and select your project.
30
+
31
+
1. From the left pane, select **Agents**.
32
+
33
+
1. Select your agent from the list, and then select **Knowledge** > **Add**.
26
34
27
35
:::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":::
28
36
29
-
1. Select **Azure AI Search** and follow the prompts to add the tool.
37
+
1. Select **Azure AI Search**.
30
38
31
39
:::image type="content" source="../../media/tools/knowledge-tools-list.png" alt-text="A screenshot showing the available knowledge tools in the Azure AI Foundry portal." lightbox="../../media/tools/knowledge-tools-list.png":::
32
40
41
+
1. Follow the prompts to add the Azure AI Search tool.
42
+
33
43
:::zone-end
34
44
35
45
:::zone pivot="python"
36
46
37
47
## Create an Azure AI Client
38
-
First, create an Azure AI Client using the endpoint of your project.
48
+
49
+
First, create an Azure AI Client using the endpoint of your Azure AI Foundry project.
#find the index name in your AI Search Azure resource page under Search Management -> Indexes
77
+
#Find the index name on the Search Management > Indexes page of your Azure AI Search service
66
78
index_name ="sample_index"
67
79
68
80
# Initialize the Azure AI Search tool
@@ -76,7 +88,8 @@ ai_search = AzureAISearchTool(
76
88
```
77
89
78
90
## Create an agent with the Azure AI Search tool enabled
79
-
Create an agent with the Azure AI Search tool attached. Change the model to the one deployed in your project.
91
+
92
+
Change the model to the one deployed in your project. You can find the model name on the **Models** tab of the Azure AI Foundry portal. You can also change the agent's name and instructions to suit your needs.
## Create an agent with the Azure AI Search tool enabled
183
-
Change the model to the one deployed in your project. You can find the model name in the Azure AI Foundry under the **Models** tab. You can also change the name and instructions of the agent to suit your needs.
200
+
201
+
Change the model to the one deployed in your project. You can find the model name on the **Models** tab of the Azure AI Foundry portal. You can also change the agent's name and instructions to suit your needs.
## Create an agent with the Azure AI Search tool enabled
354
375
355
-
Change the model to the one deployed in your project. You can find the model name in the Azure AI Foundry under the **Models** tab. You can also change the name and instructions of the agent to suit your needs.
376
+
Change the model to the one deployed in your project. You can find the model name on the **Models** tab of the Azure AI Foundry portal. You can also change the agent's name and instructions to suit your needs.
356
377
357
378
```javascript
358
379
@@ -367,7 +388,8 @@ console.log(`Created agent, agent ID : ${agent.id}`);
367
388
368
389
369
390
## Ask the agent questions about data in the index
370
-
Now that the agent is created, ask it questions about the data in your Azure AI Search index.
391
+
392
+
Now that the agent is created, you can ask it questions about the data in your search index.
@@ -440,20 +463,27 @@ for await (const m of messagesIterator) {
440
463
441
464
:::zone pivot="rest"
442
465
443
-
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`.
466
+
+ Completion of the [REST API quickstart](../../quickstart.md?pivots=rest-api#api-call-information) to get values for the `AGENT_TOKEN`, `AZURE_AI_FOUNDRY_PROJECT_ENDPOINT`, and `API_VERSION` environment variables.
444
467
445
468
## Get the connection ID for the Azure AI Search resource
446
469
447
-
To get the connection ID, navigate to the project in the Azure AI Foundry and click on the **Connected resources** tab and then select your Azure AI Search resource.
470
+
To get the connection ID:
448
471
449
-
:::image type="content" source="../../media/tools/ai-search/success-connection.png" alt-text="A screenshot of an AI Search resource connection page in Azure AI Foundry." lightbox="../../media/tools/ai-search/success-connection.png":::
472
+
1. Sign in to the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs) and select your project.
450
473
451
-
In the URL, you see the `wsid=/subscription/your-subscription-id...`, this is the connection ID you need to use. Copy everything that comes after `wsid=`.
474
+
1. On the **Overview** page, select **Open in management center**.
452
475
453
-
:::image type="content" source="../../media/tools/ai-search/connection-id.png" alt-text="A screenshot of an AI Search resource connection and how to copy the connection ID." lightbox="../../media/tools/ai-search/connection-id.png":::
476
+
1. From the left pane, select **Connected resources**, and then select your Azure AI Search service.
477
+
478
+
:::image type="content" source="../../media/tools/ai-search/success-connection.png" alt-text="A screenshot of an AI Search resource connection page in Azure AI Foundry." lightbox="../../media/tools/ai-search/success-connection.png":::
479
+
480
+
1. Copy everything that comes after `wsid=` in the browser URL.
481
+
482
+
:::image type="content" source="../../media/tools/ai-search/connection-id.png" alt-text="A screenshot of an AI Search resource connection and how to copy the connection ID." lightbox="../../media/tools/ai-search/connection-id.png":::
454
483
455
484
## Configure the Azure AI Search tool
456
-
Using the connection ID you got in the previous step, you can now configure the Azure AI Search tool to use your Azure AI Search index.
485
+
486
+
Using the connection ID you got in the previous step, configure the Azure AI Search tool to use your search index.
457
487
458
488
```bash
459
489
curl --request POST \
@@ -482,7 +512,8 @@ curl --request POST \
482
512
```
483
513
484
514
### Ask the agent questions about data in the index
485
-
Now that the agent is created, ask it questions about the data in your Azure AI Search index.
515
+
516
+
Now that the agent is created, you can ask it questions about the data in your search index.
0 commit comments