Skip to main content
For a managed knowledge base experience, see Foundry IQ. For tool optimization, see best practices.
Ground your Foundry agent’s responses in your proprietary content by connecting it to an Azure AI Search index. The Azure AI Search tool retrieves indexed documents so the Foundry model powering the agent can generate answers with inline citations, enabling accurate, source-backed responses.
If you want to use a private virtual network with the Azure AI Search tool, make sure you use Microsoft Entra project managed identity to authenticate in your Azure AI Search connection. Key-based authentication isn’t supported with private virtual networking.

Usage support

The following table shows SDK and setup support.

Prerequisites

Estimated setup time: 15-30 minutes if you have an existing search index
  • A basic or standard agent environment.
  • Install the SDK package for your preferred language. See the quickstart for details.
    • Python: pip install "azure-ai-projects>=2.0.0"
    • C#: Install the Azure.AI.Projects NuGet package
    • JavaScript/TypeScript: npm install @azure/ai-projects
    • Java: Add the com.azure:azure-ai-agents:2.0.0 dependency to your pom.xml
  • An Azure subscription and Microsoft Foundry project with:
    • Project endpoint
    • Model deployment name
    • Authentication configured (for example, DefaultAzureCredential)
  • An Azure AI Search index configured for vector search with:
    • One or more Edm.String fields that are searchable and retrievable
    • One or more Collection(Edm.Single) vector fields that are searchable
    • At least one retrievable text field that contains the content you want the agent to cite
    • A retrievable field that contains a source URL (and optionally a title) so citations can include a link
  • A connection between your Foundry project and your Azure AI Search service (see Setup).
  • For keyless authentication, assign the following Azure role-based access control (RBAC) roles to your project’s managed identity:
    • Search Index Data Contributor
    • Search Service Contributor

Configure tool parameters

Code example

  • You need the latest SDK package. For more information, see the quickstart.
  • If you’re using the REST sample, the connection ID is in the format /subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.CognitiveServices/accounts/{{foundryAccountName}}/projects/{{foundryProjectName}}/connections/{{connectionName}}.
  • If you’re using the Python, C#, or TypeScript sample, you can provide the connection name and retrieve the connection ID with the SDK.

Limitations

Keep these constraints in mind when using the Azure AI Search tool:
  • A Foundry resource with basic agent deployments does not support private Azure AI Search resources, nor Azure AI Search with public network access disabled and a private endpoint. To use a private Azure AI Search tool with your agents, deploy the standard agent with virtual network injection.
  • Private virtual network access: If you use a private virtual network with the Azure AI Search tool, you must use Microsoft Entra project managed identity (keyless authentication) in your Azure AI Search connection. Key-based authentication isn’t supported with private virtual networking. If you disabled public network access on your Azure AI Search resource, configure the connection to use managed identity instead of an API key.
  • The Azure AI Search tool can only target one index.
  • Your Azure AI Search resource and your Microsoft Foundry Agent must be in the same tenant.

Verify results

After you run a sample, validate that the agent is grounding responses from your index.
  1. Ask a question that you know is answered in a specific indexed document.
  2. Confirm the response includes citations formatted as [message_idx:search_idx†source].
  3. If you’re streaming, confirm you see url_citation annotations in the response with valid URLs.
  4. Verify the cited content matches your source documents in the search index.
If citations are missing or incorrect, see the Troubleshooting section.

Setup

In this section, you create a connection between the Microsoft Foundry project that contains your agent and the Azure AI Search service that contains your index. If you already connected your project to your search service, skip this section.
The quickest way to create a connection is through the Foundry portal. For all connection methods and supported connection types, see Add a new connection to your project.
To create the connection, you need your search service endpoint and authentication method. The following steps guide you through gathering these details.

Gather connection details

Before creating a project connection, gather your Azure AI Search service endpoint and authentication credentials. The project connection requires the endpoint of your search service and either key-based authentication or keyless authentication with Microsoft Entra ID. For keyless authentication, you must enable role-based access control (RBAC) and assign roles to your project’s managed identity. Although this method involves extra steps, it enhances security by eliminating the need for hard-coded API keys. Select the tab for your desired authentication method.
  1. Sign in to the Azure portal and select your search service.
  2. To get the endpoint:
    1. From the left pane, select Overview.
    2. Make a note of the URL, which should look like https://my-service.search.windows.net.
A screenshot of an AI Search resource Overview tab in the Azure portal.
  1. To get the API key:
    1. From the left pane, select Settings > Keys.
    2. Select Both to enable both key-based and keyless authentication, which is recommended for most scenarios.
A screenshot of an AI Search resource Keys tab in the Azure portal.
  1. Make a note of one of the keys under Manage admin keys.

Create a project connection

Create the project connection by using the search service details you gathered. Use one of the following options.
  1. Go to the Foundry portal.
  2. Open your project, then select Operate > Admin.
  3. Select your project name in the Manage all projects list.
  4. Select Add connection.
  5. Select Azure AI Search from the list of available services.
  6. Browse for and select your Azure AI Search service, then select the type of Authentication to use.
  7. Select Add connection.
For more detailed steps, see Add a new connection to your project.

Confirm the connection ID

If you use the REST or TypeScript sample, you need the project connection ID. Python
C#

Troubleshooting