Builds custom Azure AI Search indexes for arbitrary records in Orchard Core 4.0, covering index profiles, vector fields, document handlers, and deferred lifecycle indexing.
Ships in crestapps-orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate code that indexes custom records (not content items) into an Azure AI Search index profile, optionally with vectors. Model it on CrestApps.OrchardCore.AI.Memory (records, settings, indexing service) and CrestApps.OrchardCore.AI.Memory.AzureAI (provider registration and mappings).
orchardcore-azure-ai-search). For RAG over an index you already have, an AI data source is usually enough (see orchardcore-ai-data-sources).The shared module (records, neutral document, master-index setting, indexing service, lifecycle handler, re-sync handler) is identical to the Elasticsearch variant; build it as shown in orchardcore-custom-indexing-elasticsearch. This skill covers the Azure AI Search provider module and what differs.
| Piece | Namespace | Role |
|---|---|---|
AddAzureAISearchIndexingSource(type, o => ...) | OrchardCore.AzureAI | Adds the index type to Search > Indexes |
IndexProfileHandlerBase | OrchardCore.Indexing.Core.Handlers | Shapes the profile on initialize, create, update, and load |
AzureAISearchIndexMetadata, AzureAISearchIndexMap, AzureAISearchIndexMapVectorInfo, VectorSearchMappings | OrchardCore.AzureAI.Models | Field and vector configuration |
AzureAISearchConstants.ProviderName | OrchardCore.AzureAI | The provider key (AzureAISearch) |
IDocumentIndexHandler, keyed IDocumentIndexManager | OrchardCore.Indexing | Map and write documents |
IndexProfileEmbeddingMetadataAccessor | CrestApps.OrchardCore.AI.Core | Reads the embedding deployment from DataSourceIndexProfileMetadata |
public sealed class Startup : StartupBase
{
internal readonly IStringLocalizer S;
public Startup(IStringLocalizer<Startup> stringLocalizer)
{
S = stringLocalizer;
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddIndexProfileHandler<CustomerInsightAzureAISearchIndexProfileHandler>();
services.AddScoped<IDocumentIndexHandler, CustomerInsightAzureAISearchDocumentIndexHandler>();
services.AddAzureAISearchIndexingSource(CustomerInsightsConstants.IndexingTaskType, o =>
{
o.DisplayName = S["Customer insights (Azure AI Search)"];
o.Description = S["Create an Azure AI Search index for customer insight records."];
});
}
}
The provider module depends on your shared feature, OrchardCore.Indexing, and OrchardCore.AzureAI.
Azure AI Search mappings need both keys on every map: AzureFieldKey names the Azure field and IndexingKey names the DocumentIndex entry it is filled from. Missing indexing keys make upserts fail with null-key mapping errors. A vector field needs a vector search profile.
public sealed class CustomerInsightAzureAISearchIndexProfileHandler : IndexProfileHandlerBase
{
private const int DefaultDimensions = 1536;
private static readonly HashSet<string> _managedFields = new(StringComparer.OrdinalIgnoreCase)
{
CustomerInsightsConstants.ColumnNames.RecordId,
CustomerInsightsConstants.ColumnNames.CustomerId,
CustomerInsightsConstants.ColumnNames.Title,
CustomerInsightsConstants.ColumnNames.Content,
CustomerInsightsConstants.ColumnNames.UpdatedUtc,
CustomerInsightsConstants.ColumnNames.Embedding,
};
private readonly IAIDeploymentManager _deploymentManager;
private readonly IAIClientFactory _aiClientFactory;
public CustomerInsightAzureAISearchIndexProfileHandler(
IAIDeploymentManager deploymentManager,
IAIClientFactory aiClientFactory)
{
_deploymentManager = deploymentManager;
_aiClientFactory = aiClientFactory;
}
public override Task InitializingAsync(InitializingContext<IndexProfile> context)
=> SetMappingAsync(context.Model);
public override Task CreatingAsync(CreatingContext<IndexProfile> context)
=> SetMappingAsync(context.Model);
public override Task UpdatingAsync(UpdatingContext<IndexProfile> context)
=> SetMappingAsync(context.Model);
public override Task LoadedAsync(LoadedContext<IndexProfile> context)
{
if (CanHandle(context.Model))
{
var metadata = context.Model.GetOrCreate<AzureAISearchIndexMetadata>();
Normalize(metadata, dimensions: null);
context.Model.Put(metadata);
}
return Task.CompletedTask;
}
private async Task SetMappingAsync(IndexProfile indexProfile)
{
if (!CanHandle(indexProfile))
{
return;
}
var metadata = indexProfile.GetOrCreate<AzureAISearchIndexMetadata>();
Normalize(metadata, await GetEmbeddingDimensionsAsync(indexProfile));
metadata.VectorSearchMappings = new VectorSearchMappings
{
Profiles =
[
new VectorSearchProfileMap
{
Name = "default",
AlgorithmConfigurationName = "default-hnsw",
},
],
Algorithms =
[
new VectorSearchAlgorithmMap
{
Name = "default-hnsw",
Kind = VectorSearchAlgorithmMap.HnswKind,
},
],
};
indexProfile.Put(metadata);
}
// Rebuilds the managed fields once each and keeps any custom field the administrator added.
private static void Normalize(AzureAISearchIndexMetadata metadata, int? dimensions)
{
var existing = new Dictionary<string, AzureAISearchIndexMap>(StringComparer.OrdinalIgnoreCase);
var custom = new List<AzureAISearchIndexMap>();
foreach (var map in metadata.IndexMappings)
{
map.IndexingKey ??= map.AzureFieldKey;
var key = map.AzureFieldKey ?? map.IndexingKey;
if (!_managedFields.Contains(key))
{
custom.Add(map);
}
else
{
existing.TryAdd(key, map);
}
}
metadata.IndexMappings.Clear();
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.RecordId, DocumentIndex.Types.Text, m =>
{
m.IsKey = true;
m.IsFilterable = true;
}));
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.CustomerId, DocumentIndex.Types.Text, m => m.IsFilterable = true));
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.Title, DocumentIndex.Types.Text, m => m.IsSearchable = true));
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.Content, DocumentIndex.Types.Text, m => m.IsSearchable = true));
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.UpdatedUtc, DocumentIndex.Types.DateTime, m =>
{
m.IsFilterable = true;
m.IsSortable = true;
}));
metadata.IndexMappings.Add(Map(existing, CustomerInsightsConstants.ColumnNames.Embedding, DocumentIndex.Types.Vector, m =>
{
var current = m.VectorInfo?.Dimensions;
m.IsSearchable = true;
m.VectorInfo = new AzureAISearchIndexMapVectorInfo
{
Dimensions = dimensions ?? current ?? DefaultDimensions,
VectorSearchConfiguration = "default",
};
}));
foreach (var map in custom)
{
metadata.IndexMappings.Add(map);
}
}
private static AzureAISearchIndexMap Map(
Dictionary<string, AzureAISearchIndexMap> existing,
string key,
DocumentIndex.Types type,
Action<AzureAISearchIndexMap> configure)
{
if (!existing.TryGetValue(key, out var map))
{
map = new AzureAISearchIndexMap();
}
map.IndexingKey = key;
map.AzureFieldKey = key;
map.Type = type;
map.IsKey = false;
map.IsFilterable = false;
map.IsSortable = false;
map.IsSearchable = false;
configure(map);
return map;
}
private async Task<int> GetEmbeddingDimensionsAsync(IndexProfile indexProfile)
{
var deploymentName = IndexProfileEmbeddingMetadataAccessor.GetMetadata(indexProfile).GetEmbeddingDeploymentName();
var deployment = string.IsNullOrWhiteSpace(deploymentName) ? null : await _deploymentManager.FindByNameAsync(deploymentName);
if (deployment is null)
{
return DefaultDimensions;
}
var generator = await _aiClientFactory.CreateEmbeddingGeneratorAsync(deployment, builder => builder
.UseDefaultResilience()
.UseUsageLabels(purpose: AIUsagePurposes.Indexing));
if (generator is null)
{
return DefaultDimensions;
}
var embeddings = await generator.GenerateAsync(["Sample"]);
return embeddings?.Count > 0 && embeddings[0].Vector.Length > 0
? embeddings[0].Vector.Length
: DefaultDimensions;
}
private static bool CanHandle(IndexProfile indexProfile)
=> string.Equals(indexProfile.Type, CustomerInsightsConstants.IndexingTaskType, StringComparison.OrdinalIgnoreCase) &&
string.Equals(indexProfile.ProviderName, AzureAISearchConstants.ProviderName, StringComparison.OrdinalIgnoreCase);
}
Normalizing in LoadedAsync keeps reopening and saving the profile from appending duplicate managed fields, which is the bug the CrestApps memory, documents, and data source handlers fixed. Wrap the dimension probe in a try/catch that logs and falls back in production code.
public sealed class CustomerInsightAzureAISearchDocumentIndexHandler : IDocumentIndexHandler
{
public Task BuildIndexAsync(BuildDocumentIndexContext context)
{
if (context.Record is not CustomerInsightIndexDocument record ||
!context.AdditionalProperties.TryGetValue(nameof(IndexProfile), out var value) ||
value is not IndexProfile indexProfile ||
!string.Equals(indexProfile.ProviderName, AzureAISearchConstants.ProviderName, StringComparison.OrdinalIgnoreCase))
{
return Task.CompletedTask;
}
context.DocumentIndex.Set(CustomerInsightsConstants.ColumnNames.RecordId, record.RecordId, DocumentIndexOptions.Store);
context.DocumentIndex.Set(CustomerInsightsConstants.ColumnNames.CustomerId, record.CustomerId, DocumentIndexOptions.Store);
context.DocumentIndex.Set(CustomerInsightsConstants.ColumnNames.Title, record.Title, DocumentIndexOptions.Store);
context.DocumentIndex.Set(CustomerInsightsConstants.ColumnNames.Content, record.Content, DocumentIndexOptions.Store);
context.DocumentIndex.Set(CustomerInsightsConstants.ColumnNames.UpdatedUtc, record.UpdatedUtc, DocumentIndexOptions.Store);
context.DocumentIndex.Set(
CustomerInsightsConstants.ColumnNames.Embedding,
record.Embedding,
record.Embedding?.Length ?? 0,
DocumentIndexOptions.Store,
new Dictionary<string, object> { ["VectorSearchConfiguration"] = "default" });
return Task.CompletedTask;
}
}
Follow orchardcore-custom-indexing-elasticsearch for:
GetAllBySlotAsync(AIDeploymentSlotNames.Embedding), AIDeploymentFeatureNames.TextEmbedding, IndexProfileEmbeddingMetadataAccessor.StoreMetadata, locked once the index exists);IOptionsMonitor<TOptions>, embeds the record, builds a BuildDocumentIndexContext with the IndexProfile in AdditionalProperties, and calls the keyed IDocumentIndexManager;ShellScope deferred task;SynchronizedAsync handler that rebuilds a profile when it is synchronized from Search > Indexes.Embed the query with the index's deployment and send a VectorizedQuery on embedding with KNearestNeighborsCount = topN, plus an OData Filter that scopes the results (for example customerId eq '...'). Only fields declared IsFilterable can be filtered. AzureAISearchMemoryVectorSearchService in CrestApps.OrchardCore.AI.Memory.AzureAI is the reference, including its mandatory userId filter.
AzureAISearchIndexMap per field, with matching IndexingKey and AzureFieldKey.IsKey = true), filled with the same stable id as the DocumentIndex.DocumentIndex.Types.Vector, IsSearchable = true, VectorInfo.Dimensions, and a VectorSearchConfiguration that names a profile in VectorSearchMappings.IsFilterable or IsSortable; Azure rejects filters on undeclared fields.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
orchard-core, azure-ai-search, custom-indexing, vector-search, crestapps
137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts./crestapps-orchardcore:orchardcore-custom-indexing-azureaifrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcoreOther plugins' skills for the same job