Orchard Core Azure AI Search - Prompt Templates
Configure Azure AI Search
You are an Orchard Core expert. Generate code and configuration for Azure AI Search integration in Orchard Core.
Guidelines
- Enable
OrchardCore.AzureAIto manage Azure AI Search indices. - Configure the Azure AI Search connection in
appsettings.jsonunderOrchardCore.OrchardCore_AzureAISearchor through the admin UI at Settings > Search > Azure AI Search. - Use the
CreateOrUpdateIndexProfilerecipe step to create indexes (preferred over the obsoleteazureai-index-createstep). - Use the
ResetIndexrecipe step to restart indexing without deleting entries (preferred over the obsoleteazureai-index-resetstep). - Use the
RebuildIndexrecipe step to delete and recreate indexes (preferred over the obsoleteazureai-index-rebuildstep). - Supported authentication types:
ApiKey,Default,ManagedIdentity. - Use
IndexesPrefixto prevent naming conflicts when sharing an Azure AI Search instance across environments. - Enable
OrchardCore.Searchalongside Azure AI Search for frontend search functionality. - Azure AI Search uses a different field naming convention with double underscores (e.g.,
Content__ContentItem__FullText). - All recipe JSON must be wrapped in
{ "steps": [...] }. - All C# classes must use the
sealedmodifier.
Enabling Azure AI Search Features
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Search",
"OrchardCore.AzureAI",
"OrchardCore.Indexing"
],
"disable": []
}
]
}
Azure AI Search Connection Configuration
Configure in appsettings.json:
{
"OrchardCore": {
"OrchardCore_AzureAISearch": {
"Endpoint": "https://[search-service-name].search.windows.net",
"IndexesPrefix": "",
"AuthenticationType": "ApiKey",
"IdentityClientId": null,
"DisableUIConfiguration": false,
"Credential": {
"Key": "your-api-key-here"
}
}
}
}
| Property | Description |
|---|---|
Endpoint |
The Azure AI Search service endpoint URL. |
IndexesPrefix |
Prefix for all index names. Use environment names (e.g., "staging-") to prevent conflicts when sharing a single Azure AI Search instance. |
AuthenticationType |
"ApiKey" for key-based, "Default" for default Azure credentials, or "ManagedIdentity" for managed identity. |
IdentityClientId |
Optional client ID for user-assigned managed identity. Omit for system-assigned identity. |
DisableUIConfiguration |
When true, disables per-tenant UI configuration and forces all tenants to use appsettings values. |
Credential.Key |
The API key for the Azure AI Search service. Required for ApiKey authentication. |
Creating an Azure AI Search Index Profile (Recommended)
{
"steps": [
{
"name": "CreateOrUpdateIndexProfile",
"indexes": [
{
"Name": "BlogPostsAI",
"IndexName": "blogposts",
"ProviderName": "AzureAISearch",
"Type": "Content",
"Properties": {
"ContentIndexMetadata": {
"IndexLatest": false,
"IndexedContentTypes": ["BlogPost"],
"Culture": "any"
},
"AzureAISearchIndexMetadata": {
"AnalyzerName": "standard"
},
"AzureAISearchDefaultQueryMetadata": {
"QueryAnalyzerName": "standard.lucene",
"DefaultSearchFields": [
"Content__ContentItem__FullText"
]
}
}
}
]
}
]
}
| Property | Description |
|---|---|
Name |
Unique display name for the index profile. |
IndexName |
Physical index name in Azure AI Search. |
ProviderName |
Must be "AzureAISearch". |
Type |
Source category, typically "Content" for content items. |
IndexLatest |
When true, indexes both published and draft items. |
IndexedContentTypes |
Array of content type names to include. |
Culture |
"any" for all cultures or a specific culture code. |
AnalyzerName |
Azure AI Search analyzer (e.g., "standard", "standard.lucene"). |
QueryAnalyzerName |
Analyzer used at query time. |
DefaultSearchFields |
Fields to search across. Uses double underscores as separators (e.g., Content__ContentItem__FullText). |
Legacy Index Creation (Obsolete)
{
"steps": [
{
"name": "azureai-index-create",
"Indices": [
{
"Source": "Contents",
"IndexName": "articles",
"IndexLatest": false,
"IndexedContentTypes": ["Article"],
"AnalyzerName": "standard.lucene",
"Culture": "any"
}
]
}
]
}
Reset Azure AI Search Index
Restarts indexing from the beginning without deleting existing entries:
{
"steps": [
{
"name": "ResetIndex",
"indexNames": [
"BlogPostsAI"
]
}
]
}
To reset all indices:
{
"steps": [
{
"name": "ResetIndex",
"IncludeAll": true
}
]
}
Rebuild Azure AI Search Index
Deletes and recreates the full index content:
{
"steps": [
{
"name": "RebuildIndex",
"indexNames": [
"BlogPostsAI"
]
}
]
}
To rebuild all indices:
{
"steps": [
{
"name": "RebuildIndex",
"IncludeAll": true
}
]
}
Indexing Custom Data
Register a custom indexing source in Startup.cs:
using OrchardCore.Modules;
namespace MyModule;
[Feature("MyModule.CustomAzureAIIndex")]
public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAzureAISearchIndexingSource("CustomSource", o =>
{
o.DisplayName = S["Custom Source"];
o.Description = S["Create an Azure AI Search index based on a custom data source."];
});
}
}
For custom index field mapping, implement IIndexProfileHandler and populate AzureAISearchIndexMetadata with IndexMappings in the CreatingAsync and UpdatingAsync methods. Use IndexProfileHandlerBase to simplify the implementation.
To capture custom UI data related to your source, implement DisplayDriver<IndexEntity>.
Frontend Search Integration
When OrchardCore.Search is enabled alongside Azure AI Search:
- Navigate to Settings > Search > Site Search in the admin dashboard.
- Select the Azure AI Search index as the default search provider.
- The
/searchroute becomes available for frontend search. - Configure search permissions per role to control which indexes are queryable by anonymous or authenticated users.