OrchardCMS/OrchardCore · error · ArgumentOutOfRangeException
Unsupported Azure AI Search vector algorithm kind.
Error message
Unsupported Azure AI Search vector algorithm kind.
What it means
CreateVectorSearchAlgorithm maps the configured algorithm Kind to the Azure SDK's VectorSearchAlgorithm; when the metadata contains a Kind value outside the supported set, this ArgumentOutOfRangeException is thrown. It is an internal invariant check against unexpected enum values persisted in index metadata.
Solutions
- Open the index profile and re-select a supported vector algorithm (Hnsw or ExhaustiveKnn)
- Fix the algorithm Kind value in the stored AzureAISearchIndexMetadata
- Re-create the index profile with a valid algorithm configuration
Example fix
// before
"algorithm": { "kind": "DiskANN" }
// after
"algorithm": { "kind": "Hnsw" } Defensive patterns
Strategy: validation
Validate before calling
var valid = new[] { "hnsw", "exhaustiveKnn" }; var ok = valid.Contains(config.Kind, StringComparer.OrdinalIgnoreCase); Type guard
bool isValidKind = Enum.IsDefined(typeof(AzureAISearchVectorAlgorithmKind), config.Kind);
Try / catch
try { await EnsureAlgorithm(index); } catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "algorithm") { /* reconfigure algorithm kind */ } Prevention
- Only select supported algorithm kinds in index settings
- Re-validate index profiles after module upgrades
- Never manually edit stored metadata enum values
When it happens
Trigger: Calling EnsureAlgorithm/CreateVectorSearchAlgorithm with an AzureAISearchVectorAlgorithmConfig whose Kind is neither Hnsw nor ExhaustiveKnn (e.g., stale or hand-edited metadata).
Common situations: Index metadata written by an older module version; JSON metadata manually edited with an invalid kind; future enum values from newer versions read by older code.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- The calendar is not supported.
- Unexpected merge array handling when merging JSON.
- The index does not have a key field.
- The type ' ' is not support by Azure AI Search
- Unable to create a safe index prefix for AI Search…
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/3c9e546c2cb15007.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.AzureAI.Core/Services/AzureAISearchIndexManager.cs:343
return hnswConfiguration;
}
if (algorithm.Kind.EqualsOrdinalIgnoreCase(VectorSearchAlgorithmMap.ExhaustiveKnnKind))
{
var exhaustiveKnnConfiguration = new ExhaustiveKnnAlgorithmConfiguration(algorithm.Name);
if (algorithm.ExhaustiveKnnParametersMap is not null)
{
exhaustiveKnnConfiguration.Parameters = new ExhaustiveKnnParameters
{
Metric = ToVectorSearchAlgorithmMetric(algorithm.ExhaustiveKnnParametersMap.Metric),
};
}
return exhaustiveKnnConfiguration;
}
throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm.Kind, "Unsupported Azure AI Search vector algorithm kind.");
}
private static VectorSearchAlgorithmMetric? ToVectorSearchAlgorithmMetric(string metric)
=> string.IsNullOrWhiteSpace(metric) ? null : new VectorSearchAlgorithmMetric(metric);
private static string GetVectorSearchProfileName(AzureAISearchIndexMetadata metadata, AzureAISearchIndexMapVectorInfo vectorInfo)
{
if (!string.IsNullOrWhiteSpace(vectorInfo?.VectorSearchConfiguration))
{
return vectorInfo.VectorSearchConfiguration;
}
var configuredProfileName = GetConfiguredProfiles(metadata.VectorSearchMappings).FirstOrDefault()?.Name;
return string.IsNullOrWhiteSpace(configuredProfileName)
? VectorSearchMappings.DefaultProfileName
: configuredProfileName;
}View on GitHub (pinned to 4306c0717f)