Aspire.Azure.Search.Documents 13.1.0

Prefix Reserved
dotnet add package Aspire.Azure.Search.Documents --version 13.1.0
                    
NuGet\Install-Package Aspire.Azure.Search.Documents -Version 13.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aspire.Azure.Search.Documents" Version="13.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aspire.Azure.Search.Documents" Version="13.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Aspire.Azure.Search.Documents" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aspire.Azure.Search.Documents --version 13.1.0
                    
#r "nuget: Aspire.Azure.Search.Documents, 13.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aspire.Azure.Search.Documents@13.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aspire.Azure.Search.Documents&version=13.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Aspire.Azure.Search.Documents&version=13.1.0
                    
Install as a Cake Tool

Aspire.Azure.Search.Documents library

Registers SearchIndexClient as a singleton in the DI container for connecting to Azure AI Search. Enables corresponding logging and telemetry.

Getting started

Prerequisites

Install the package

Install the Aspire Azure AI Search library with NuGet:

dotnet add package Aspire.Azure.Search.Documents

Usage example

In the AppHost.cs file of your project, call the AddAzureSearchClient extension method to register an SearchIndexClient for use via the dependency injection container. The method takes a connection name parameter.

builder.AddAzureSearchClient("searchConnectionName");

You can then retrieve the SearchIndexClient instance using dependency injection. For example, to retrieve the client from a Web API controller:

private readonly SearchIndexClient _indexClient;

public SearchController(SearchIndexClient indexClient)
{
    _indexClient = indexClient;
}

You can also retrieve a SearchClient which can be used for querying, by calling GetSearchClient(string indexName) method on the SearchIndexClient instance as follows:

private readonly SearchIndexClient _indexClient;

public SearchController(SearchIndexClient indexClient)
{
    _indexClient = indexClient;
}

public async Task<long> GetDocumentCountAsync(string indexName, CancellationToken cancellationToken)
{
    var searchClient = _indexClient.GetSearchClient(indexName);
    var documentCountResponse = await searchClient.GetDocumentCountAsync(cancellationToken);
    return documentCountResponse.Value;
}

See the Azure AI Search client library for .NET for examples on using the SearchIndexClient.

Configuration

The Aspire Azure AI Search library provides multiple options to configure the Azure AI Search Service based on the requirements and conventions of your project. Note that either an Endpoint or a ConnectionString is required to be supplied.

Use a connection string

A connection can be constructed from the Keys and Endpoint tab with the format Endpoint={endpoint};Key={key};. You can provide the name of the connection string when calling builder.AddAzureSearchClient():

builder.AddAzureSearchClient("searchConnectionName");

And then the connection string will be retrieved from the ConnectionStrings configuration section. Two connection formats are supported:

Account Endpoint

The recommended approach is to use an Endpoint, which works with the AzureSearchSettings.Credential property to establish a connection. If no credential is configured, the DefaultAzureCredential is used.

{
  "ConnectionStrings": {
    "searchConnectionName": "https://{search_service}.search.windows.net/"
  }
}
Connection string

Alternatively, a custom connection string can be used.

{
  "ConnectionStrings": {
    "searchConnectionName": "Endpoint=https://{search_service}.search.windows.net/;Key={account_key};"
  }
}

Use configuration providers

The Aspire Azure AI Search library supports Microsoft.Extensions.Configuration. It loads the AzureSearchSettings and SearchClientOptions from configuration by using the Aspire:Azure:Search:Documents key. Example appsettings.json that configures some of the options:

{
  "Aspire": {
    "Azure": {
      "Search": {
        "Documents": {
          "DisableTracing": false,
        }
      }
    }
  }
}

Use inline delegates

You can also pass the Action<AzureSearchSettings> configureSettings delegate to set up some or all the options inline, for example to disable tracing from code:

builder.AddAzureSearchClient("searchConnectionName", settings => settings.DisableTracing = true);

You can also setup the SearchClientOptions using the optional Action<IAzureClientBuilder<SearchIndexClient, SearchClientOptions>> configureClientBuilder parameter of the AddAzureSearchClient method. For example, to set the client ID for this client:

builder.AddAzureSearchClient("searchConnectionName", configureClientBuilder: builder => builder.ConfigureOptions(options => options.Diagnostics.ApplicationId = "CLIENT_ID"));

AppHost extensions

In your AppHost project, install the Aspire Azure AI Search Hosting library with NuGet:

dotnet add package Aspire.Hosting.Azure.Search

Then, in the AppHost.cs file of AppHost, add an Azure AI Search service and consume the connection using the following methods:

var search = builder.ExecutionContext.IsPublishMode
    ? builder.AddAzureSearch("search")
    : builder.AddConnectionString("search");

var myService = builder.AddProject<Projects.MyService>()
                       .WithReference(search);

The AddAzureSearch method adds an Azure AI Search resource to the builder. Or AddConnectionString can be used to read connection information from the AppHost's configuration (for example, from "user secrets") under the ConnectionStrings:search config key. The WithReference method passes that connection information into a connection string named search in the MyService project. In the Program.cs file of MyService, the connection can be consumed using:

builder.AddAzureSearchClient("search");

Additional documentation

Feedback & contributing

https://github.com/dotnet/aspire

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Aspire.Azure.Search.Documents:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
dotnet/extensions
This repository contains a suite of libraries that provide facilities commonly needed when creating production-ready applications.
Azure-Samples/eShopLite
eShopLite is a set of reference .NET applications implementing an eCommerce site with features like Semantic Search, MCP, Reasoning models and more.
Version Downloads Last Updated
13.1.0 2,372 12/17/2025
13.0.2 2,716 12/4/2025
13.0.1 1,709 11/26/2025 13.0.1 is deprecated because it is no longer maintained.
13.0.0 6,462 11/11/2025 13.0.0 is deprecated because it is no longer maintained.
9.5.2 7,002 10/23/2025 9.5.2 is deprecated because it is no longer maintained.
9.5.1 20,387 10/3/2025 9.5.1 is deprecated because it is no longer maintained.
9.5.0 4,747 9/25/2025 9.5.0 is deprecated because it is no longer maintained.
9.4.2 7,576 9/2/2025 9.4.2 is deprecated because it is no longer maintained.
9.4.1 4,477 8/12/2025 9.4.1 is deprecated because it is no longer maintained.
9.4.0 3,572 7/29/2025 9.4.0 is deprecated because it is no longer maintained.
9.3.1 21,845 6/10/2025 9.3.1 is deprecated because it is no longer maintained.
9.3.0 7,309 5/19/2025 9.3.0 is deprecated because it is no longer maintained.
9.2.1 23,172 4/24/2025 9.2.1 is deprecated because it is no longer maintained.
9.2.0 2,823 4/10/2025 9.2.0 is deprecated because it is no longer maintained.
9.1.0 40,932 2/25/2025 9.1.0 is deprecated because it is no longer maintained.
9.0.0 11,180 11/12/2024 9.0.0 is deprecated because it is no longer maintained.
9.0.0-rc.1.24511.1 199 10/15/2024 9.0.0-rc.1.24511.1 is deprecated because it is no longer maintained.
8.2.2 4,444 10/24/2024 8.2.2 is deprecated because it is no longer maintained.
8.2.1 3,359 9/26/2024 8.2.1 is deprecated because it is no longer maintained.
8.2.0 2,771 8/29/2024 8.2.0 is deprecated because it is no longer maintained.
8.1.0 2,318 7/23/2024 8.1.0 is deprecated because it is no longer maintained.
8.0.2 3,072 6/28/2024 8.0.2 is deprecated because it is no longer maintained.
8.0.1 2,600 5/21/2024 8.0.1 is deprecated because it is no longer maintained.
8.0.0 1,636 5/21/2024 8.0.0 is deprecated because it is no longer maintained.
8.0.0-preview.7.24251.11 222 5/7/2024 8.0.0-preview.7.24251.11 is deprecated because it is no longer maintained.
8.0.0-preview.6.24214.1 209 4/23/2024 8.0.0-preview.6.24214.1 is deprecated because it is no longer maintained.
8.0.0-preview.5.24201.12 230 4/9/2024 8.0.0-preview.5.24201.12 is deprecated because it is no longer maintained.
8.0.0-preview.4.24156.9 265 3/12/2024 8.0.0-preview.4.24156.9 is deprecated because it is no longer maintained.