# AzureAISearchToolResource

- Kind: `class`
- Package: [Aspire.Hosting.Foundry](/reference/api/csharp/aspire.hosting.foundry.md)
- Version: `13.4.0-preview.1.26281.18`
- Namespace: `Aspire.Hosting.Foundry`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Foundry/ToolResources/AzureAISearchToolResource.cs)
- Inherits: [FoundryToolResource](/reference/api/csharp/aspire.hosting.foundry/foundrytoolresource.md)

A Foundry tool resource that grounds an agent's responses using data from an Azure AI Search index.

## Definition

```csharp
namespace Aspire.Hosting.Foundry;

public class AzureAISearchToolResource
    : Aspire.Hosting.Foundry.FoundryToolResource
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `Aspire.Hosting.Foundry/AzureAISearchToolResource`

## Remarks

After creating this tool with [PromptAgentBuilderExtensions.AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addaisearchtool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string), link it to an `Azure.AzureSearchResource` using [PromptAgentBuilderExtensions.WithReference(IResourceBuilder<AzureAISearchToolResource>, IResourceBuilder<AzureSearchResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-azureaisearchtoolresource-iresourcebuilder-azuresearchresource). The connection identifier is resolved at deploy time when the agent definition is created.

## Constructors

- [AzureAISearchToolResource(string, AzureCognitiveServicesProjectResource)](/reference/api/csharp/aspire.hosting.foundry/azureaisearchtoolresource/constructors.md#constructor-string-azurecognitiveservicesprojectresource) -- Creates a new instance of the [AzureAISearchToolResource](/reference/api/csharp/aspire.hosting.foundry/azureaisearchtoolresource.md) class.

## Properties

- [IndexName](/reference/api/csharp/aspire.hosting.foundry/azureaisearchtoolresource/properties.md#indexname) : `string?` `get; set` -- Gets or sets the optional search index name to query. If not set, the tool will use a default or prompt-specified index at runtime.
- [SearchResource](/reference/api/csharp/aspire.hosting.foundry/azureaisearchtoolresource/properties.md#searchresource) : `AzureSearchResource?` `get` -- Gets or sets the Azure AI Search resource backing this tool. Set by [PromptAgentBuilderExtensions.WithReference(IResourceBuilder<AzureAISearchToolResource>, IResourceBuilder<AzureSearchResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-azureaisearchtoolresource-iresourcebuilder-azuresearchresource).

## Methods

- [ToAgentToolAsync(CancellationToken)](/reference/api/csharp/aspire.hosting.foundry/azureaisearchtoolresource/methods.md#toagenttoolasync-cancellationtoken) : `Task<ResponseTool>` -- Converts this tool definition into the SDK `Responses.ResponseTool` representation.
