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-services/agents/how-to/tools/azure-ai-search.md
+2-307Lines changed: 2 additions & 307 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,318 +36,13 @@ Use an existing Azure AI Search index with the agent's Azure AI Search tool.
36
36
::: zone-end
37
37
38
38
::: zone pivot="setup"
39
-
## Setup: Create an agent that can use an existing Azure AI Search index
40
-
#### 1. Prerequisite: Have an existing Azure AI Search index
41
-
A prerequisite of using the Azure AI Search tool is to have an existing Azure AI Search index. If you don't have an existing index, you can create one in the Azure portal or via REST API.
42
-
-[Quickstart: Create a vector index using the Azure portal](../../../../search/search-get-started-portal-import-vectors.md)
43
-
-[Quickstart: Create a vector index using REST API](../../../../search/search-get-started-vector.md)
44
-
#### 2. Complete the agent setup
45
-
-**Option 1: Standard Agent Setup using existing AI Search resource** If you want your agent to use an existing AI Search resource to create new indexes or bring existing ones you should use the [standard agent setup and add your AI Search resource ID](../../quickstart.md).
46
-
- You can provide your Azure AI Search resource ID in the bicep file. Your resource ID should be in the format: `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}`.
47
-
-**Option 2: Standard Agent Setup** If you want to create a new Azure AI Search resource for your agents to use when creating new indexes follow the [standard agent setup](../../quickstart.md).
48
-
49
-
#### 3. Create a project connection to the Azure AI Search resource with the index you want to use
50
-
If you already connected the AI Search resource that contains the index you want to use to your project, skip this step.
51
-
52
-
##### Get your Azure AI Search resource connection key and endpoint
53
-
- Access your Azure AI Search resource.
54
-
- In the Azure portal, navigate to the AI Search resource that contains the index you want to use.
55
-
- Copy the connection endpoint.
56
-
- In the Overview tab, copy the URL of your resource. The URL should be in the format `https://<your-resource-name>.search.windows.net/`.
57
-
:::image type="content" source="../../media/tools/ai-search/connection-endpoint.png" alt-text="A screenshot of an AI Search resource Overview tab in the Azure portal." lightbox="../../media/tools/ai-search/connection-endpoint.png":::
58
-
59
-
- Verify API Acccess control is set to **Both** and copy one of the keys under **Manage admin keys**.
60
-
- From the left-hand navigation bar, scroll down to the Settings section and select **Keys**.
61
-
- Under the **API Access Control** section, ensure the option **Both** API key and Role-based access control is selected.
62
-
- If you want the connection to use API Keys for authentication, copy one of the keys under **Manage admin keys**.
63
-
:::image type="content" source="../../media/tools/ai-search/acs-azure-portal.png" alt-text="A screenshot of an AI Search resource Keys tab in the Azure portal." lightbox="../../media/tools/ai-search/acs-azure-portal.png":::
64
-
65
-
##### Create an Azure AI Search project connection
66
-
67
-
**Azure CLI**
68
-
```azurecli
69
-
az ml connection create --file {connection.yml} --resource-group {my_resource_group} --workspace-name {my_hub_name}
70
-
```
71
-
72
-
You can use either an API key or credential-less YAML configuration file. For more information on the YAML configuration file, see the [Azure AI Search connection YAML schema](../../../../machine-learning/reference-yaml-connection-ai-search.md):
73
-
- API Key example:
74
-
75
-
```yml
76
-
name: myazaics_apk
77
-
type: azure_ai_search
78
-
endpoint: https://contoso.search.windows.net/
79
-
api_key: XXXXXXXXXXXXXXX
80
-
```
81
-
82
-
- Credential-less
83
-
84
-
```yml
85
-
name: myazaics_ei
86
-
type: azure_ai_search
87
-
endpoint: https://contoso.search.windows.net/
88
-
```
89
-
90
-
**Python**
91
-
```python
92
-
from azure.ai.ml.entities import AzureAISearchConnection
93
-
94
-
# constrict an Azure AI Search connection
95
-
my_connection_name = "myaiservivce"
96
-
my_endpoint = "demo.endpoint" # this could also be called target
97
-
my_api_keys = None # leave blank for Authentication type = AAD
1. In Azure AI Foundry, navigate to the project you created in the agent setup. Click on **Open in management center**.
109
-
:::image type="content" source="../../media/tools/ai-search/project-studio.png" alt-text="A screenshot of a project in Azure AI Foundry." lightbox="../../media/tools/ai-search/project-studio.png":::
110
-
111
-
2. Click on the **Connections** tab and select **Add Connection**.
112
-
:::image type="content" source="../../media/tools/ai-search/project-connections-page.png" alt-text="A screenshot of the project connections page." lightbox="../../media/tools/ai-search/project-connections-page.png":::
113
-
114
-
3. Select **Azure AI Search**.
115
-
:::image type="content" source="../../media/tools/ai-search/select-acs.png" alt-text="A screenshot of the Azure AI Search connection type the user should select." lightbox="../../media/tools/ai-search/select-acs.png":::
116
-
117
-
4. Provide the required connection details for the Azure AI Search resource you want to use. Both Managed Identity and Key-based authentication are supported. Once all the fields are filled in, click **Add connection**.
118
-
:::image type="content" source="../../media/tools/ai-search/acs-connection-2.png" alt-text="A screenshot the required fields to add a new Azure AI Search connection." lightbox="../../media/tools/ai-search/acs-connection-2.png":::
119
-
120
-
5. Verify that the connection was successfully created and now appears in the project's Connections tab.
121
-
:::image type="content" source="../../media/tools/ai-search/success-acs-connection.png" alt-text="A screenshot of the project connections page with a new Azure AI Search connection added." lightbox="../../media/tools/ai-search/success-acs-connection.png":::
### Step 2: Get the connection ID for the Azure AI Search resource
180
-
181
-
Get the connection ID of the Azure AI Search connection in the project. You can use the code snippet to print the connection ID of all the Azure AI Search connections in the project.
182
-
183
-
# [Python](#tab/python)
184
-
185
-
```python
186
-
# AI Search resource connection ID
187
-
# This code prints out the connection ID of all the Azure AI Search connections in the project
188
-
# If you have more than one AI search connection, make sure to select the correct one that contains the index you want to use.
if (connections?.Value==null||connections.Value.Count==0)
200
-
{
201
-
thrownewInvalidOperationException("No connections found for the Azure AI Search.");
202
-
}
203
-
204
-
```
205
-
---
206
-
The second way to get the connection ID is to navigate to the project in the Azure AI Foundry and click on the **Connected resources** tab and then select your Azure AI Search resource.
207
-
:::image type="content" source="../../media/tools/ai-search/success-acs-connection.png" alt-text="A screenshot of an AI Search resource connection page in Azure AI Foundry." lightbox="../../media/tools/ai-search/success-acs-connection.png":::
208
-
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=.
209
-
:::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":::
210
-
211
-
### Step 3: Configure the Azure AI Search tool
212
-
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.
213
-
# [Python](#tab/python)
214
-
```python
215
-
# TO DO: replace this value with the connection ID of the search index
### Step 4: Create an agent with the Azure AI Search tool enabled
241
-
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.
### Step 5: Ask the agent questions about data in the index
269
-
Now that the agent is created, ask it questions about the data in your Azure AI Search index. The example assumes your Azure AI Search index contains information about health care plans.
270
-
# [Python](#tab/python)
271
-
```python
272
-
# Create a thread
273
-
thread = project_client.agents.create_thread()
274
-
print(f"Created thread, thread ID: {thread.id}")
275
-
276
-
# Create a message
277
-
message = project_client.agents.create_message(
278
-
thread_id=thread.id,
279
-
role="user",
280
-
content="what are my health insurance plan coverage types?",
0 commit comments