Crestapps core azure ai search

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core azure ai search is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for using Azure AI Search as the CrestApps.Core indexing and vector backend. Covers CrestApps.Core.Azure.AISearch and CrestApps.Core.AI.Azure.AISearch, AddAzureAISearch on the indexing builder with AddAIDocuments, AddAIDataSources and AddAIMemory, AddCoreAzureAISearchServices with a configurat

How to use this skill

Skill file

CrestApps.Core Azure AI Search

Use Azure AI Search as the knowledge-base backend for AI documents, AI data sources and AI memory. For the data source model see crestapps-core-data-sources.

Registration

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai.AddAzureOpenAI())
    .AddIndexingServices(indexing => indexing
        .AddYesSqlStores()
        .AddAzureAISearch(
            builder.Configuration.GetSection("CrestApps:AzureAISearch"),
            azureAISearch => azureAISearch
                .AddAIDocuments()
                .AddAIDataSources()
                .AddAIMemory())));

| Call | Package | Adds |

|---|---|---|

| AddCoreAzureAISearchServices(section) | CrestApps.Core.Azure.AISearch | AzureAISearchConnectionOptions, IAzureAISearchClientFactory, a singleton SearchIndexClient, keyed IDataSourceContentManager, IDataSourceDocumentReader, IODataFilterTranslator, ISearchIndexManager, ISearchDocumentManager |

| AddAzureAISearchODataFilterTranslator() | CrestApps.Core.Azure.AISearch | only the keyed translator, for hosts that bring their own clients |

| AddAIDocuments() / AddCoreAzureAISearchAIDocumentSource() | CrestApps.Core.AI.Azure.AISearch | AIDocuments index-profile source, profile handler, keyed IVectorSearchService |

| AddAIDataSources() / AddCoreAzureAISearchAIDataSource() | CrestApps.Core.AI.Azure.AISearch | DataSource index-profile source, keyed AzureAISearchAIDataSourceSourceHandler, and AddCoreAIDataSourceRag() |

| AddAIMemory() / AddCoreAzureAISearchAIMemorySource() | CrestApps.Core.AI.Azure.AISearch | AIMemory index-profile source, profile handler, keyed IMemoryVectorSearchService |

Every keyed service uses AISearchConstants.ProviderName ("AzureAISearch").

Configuration

{
  "CrestApps": {
    "AzureAISearch": {
      "Endpoint": "https://my-search.search.windows.net",
      "AuthenticationType": "Default",
      "IdentityClientId": "",
      "IndexPrefix": ""
    }
  }
}

AzureAISearchConnectionOptions: Endpoint, AuthenticationType (Default uses DefaultAzureCredential and is the fallback for empty or unknown values, ApiKey, ManagedIdentity), ApiKey, IdentityClientId (user-assigned identity) and IndexPrefix. The older IndexesPrefix is still honored when IndexPrefix is empty. Prefer managed identity in Azure, and keep any admin key out of source control. Vector search needs the Basic tier or higher.

Filters and Typed Columns

External Azure AI Search Sources

An AIDataSource with Source = AIDataSourceSourceTypes.AzureAISearch reads a remote index configured on the data source itself: Endpoint, AuthenticationType, IndexName, IdentityClientId, and an ApiKey protected with AIDataSourceProtectionConstants.SourceSecretPurpose. This is separate from the backend options above. Notify the sync pipeline with IAIDataSourceChangeNotifier when the remote index changes.

Supplying Your Own Client

A host that already holds a SearchIndexClient, such as a multi-tenant host with one client per tenant, passes a Func<IServiceProvider, SearchIndexClient> instead of a configuration section:

using CrestApps.Core.Azure.AISearch;
using CrestApps.Core.AI.Azure.AISearch;
using CrestApps.Core.Infrastructure;

// Every core service with the host's client. No IAzureAISearchClientFactory or SearchIndexClient is registered.
builder.Services.AddCoreAzureAISearchServices(sp => sp.GetRequiredService<TenantSearchClients>().IndexClient);

// AI search services alone, without the index profile sources or handlers.
builder.Services
    .AddAzureAISearchVectorSearchService(
        sp => sp.GetRequiredService<TenantSearchClients>().IndexClient,
        new DocumentIndexColumnNames { FileName = "file_name" })
    .AddAzureAISearchMemoryVectorSearchService(sp => sp.GetRequiredService<TenantSearchClients>().IndexClient)
    .AddAzureAISearchAIDataSourceSourceHandler();

| Method | Registers |

|---|---|

| AddCoreAzureAISearchServices(Func<IServiceProvider, SearchIndexClient>) | content manager, document reader, filter translator, index and document managers with the supplied client |

| AddAzureAISearchDataSourceContentManager(clientFactory) / AddAzureAISearchDataSourceDocumentReader(clientFactory) | one service each |

| AddAzureAISearchVectorSearchService(clientFactory, DocumentIndexColumnNames columnNames = null) | keyed IVectorSearchService for AI documents |

| AddAzureAISearchMemoryVectorSearchService(clientFactory) | keyed IMemoryVectorSearchService |

| AddAzureAISearchAIDataSourceSourceHandler() or (Func<IServiceProvider, IAzureAISearchClientFactory>) | the external-source handler, with the default or a supplied client factory |

Escaping Filter Values

Build any filter from untrusted values with ODataFilter (CrestApps.Core.Azure.AISearch); every filter the provider builds goes through it:

ODataFilter.Quote("O'Brien");                    // 'O''Brien'
ODataFilter.Equal("userId", userId);             // userId eq '...'
ODataFilter.AnyEqual("referenceId", ["a", "b"]); // referenceId eq 'a' or referenceId eq 'b'
ODataFilter.Escape("O'Brien");                   // O''Brien

Quote(null) returns the OData null literal. Field names are written as is, so pass only names your code controls.

Troubleshooting

| Symptom | Check |

|---|---|

| Index profile creation reports the provider is not configured | Endpoint missing from the bound section |

| 403 or credential errors | AuthenticationType, role assignments for the managed identity, or the admin key |

| Filter request fails | declare filters and the filtered sub-fields as filterable |

| Filter ignored with a warning | no keyed translator; call AddAzureAISearchODataFilterTranslator() |

Upgrading Within 2.0 Previews

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.