microsoft/semantic-kernel · critical · NotSupportedException

AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingS

Error message

AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.

What it means

VectorStoreRAG's Program.cs switches on appConfig.RagConfig.AIEmbeddingService and only supports 'AzureOpenAIEmbeddings' and 'OpenAIEmbeddings'. Any other value falls through to the default branch and throws NotSupportedException at application startup, preventing the embedding generator from being registered.

Source

Thrown at dotnet/samples/Demos/VectorStoreRAG/Program.cs:66

        throw new NotSupportedException($"AI Chat Service type '{appConfig.RagConfig.AIChatService}' is not supported.");
}

switch (appConfig.RagConfig.AIEmbeddingService)
{
    case "AzureOpenAIEmbeddings":
        builder.Services.AddSingleton<IEmbeddingGenerator>(
            sp => new AzureOpenAIClient(new Uri(appConfig.AzureOpenAIEmbeddingsConfig.Endpoint), new AzureCliCredential())
                .GetEmbeddingClient(appConfig.AzureOpenAIEmbeddingsConfig.DeploymentName)
                .AsIEmbeddingGenerator());
        break;
    case "OpenAIEmbeddings":
        builder.Services.AddSingleton<IEmbeddingGenerator>(
            sp => new OpenAIClient(appConfig.OpenAIEmbeddingsConfig.ApiKey)
                .GetEmbeddingClient(appConfig.OpenAIEmbeddingsConfig.ModelId)
                .AsIEmbeddingGenerator());
        break;
    default:
        throw new NotSupportedException($"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.");
}

// Add the configured vector store record collection type to the
// dependency injection container.
switch (appConfig.RagConfig.VectorStoreType)
{
    case "AzureAISearch":
        kernelBuilder.Services.AddAzureAISearchCollection<TextSnippet<string>>(
            appConfig.RagConfig.CollectionName,
            new Uri(appConfig.AzureAISearchConfig.Endpoint),
            new AzureKeyCredential(appConfig.AzureAISearchConfig.ApiKey));
        break;
    case "CosmosMongoDB":
        kernelBuilder.Services.AddCosmosMongoCollection<TextSnippet<string>>(
            appConfig.RagConfig.CollectionName,
            appConfig.CosmosMongoConfig.ConnectionString,
            appConfig.CosmosMongoConfig.DatabaseName);
        break;

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Set RagConfig:AIEmbeddingService to exactly 'AzureOpenAIEmbeddings' or 'OpenAIEmbeddings' in your configuration source.
  2. Add a new case arm for additional embedding providers if needed.
  3. Verify AIChatService and AIEmbeddingService are set to compatible, distinct values.
  4. Add startup validation that lists the supported values in the error message.

Example fix

// before
default:
    throw new NotSupportedException($"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.");

// after — list valid values in the error
default:
    throw new NotSupportedException(
        $"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported. " +
        "Valid values: 'AzureOpenAIEmbeddings', 'OpenAIEmbeddings'.");
Defensive patterns

Strategy: validation

Validate before calling

var validEmbeddingServices = new[] { "AzureOpenAIEmbeddings", "OpenAIEmbeddings" };
if (!validEmbeddingServices.Contains(appConfig.RagConfig.AIEmbeddingService))
    throw new ArgumentException($"AIEmbeddingService must be one of: {string.Join(", ", validEmbeddingServices)}. Got: '{appConfig.RagConfig.AIEmbeddingService}'");

Type guard

bool IsValidEmbeddingService(string? s) => s is "AzureOpenAIEmbeddings" or "OpenAIEmbeddings";

Prevention

When it happens

Trigger: The RagConfig.AIEmbeddingService configuration value is set to a string that is not exactly 'AzureOpenAIEmbeddings' or 'OpenAIEmbeddings' — e.g., 'AzureOpenAI', 'Ollama', null, or a typo.

Common situations: Configuration confusion where AIChatService is set but AIEmbeddingService is left blank or defaults incorrectly; typo in the section key; using a non-OpenAI embedding provider not yet wired into this sample; mixing up the chat and embedding service values.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/d9d277c9c1d26ac4. Report an issue: GitHub.