{"record":{"id":"d9d277c9c1d26ac4","repo":"microsoft/semantic-kernel","slug":"ai-embedding-service-type-appconfig-ragconfig-ai","errorCode":null,"errorMessage":"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.","messagePattern":"AI Embedding Service type '(.+?)' is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"dotnet/samples/Demos/VectorStoreRAG/Program.cs","lineNumber":66,"sourceCode":"        throw new NotSupportedException($\"AI Chat Service type '{appConfig.RagConfig.AIChatService}' is not supported.\");\n}\n\nswitch (appConfig.RagConfig.AIEmbeddingService)\n{\n    case \"AzureOpenAIEmbeddings\":\n        builder.Services.AddSingleton<IEmbeddingGenerator>(\n            sp => new AzureOpenAIClient(new Uri(appConfig.AzureOpenAIEmbeddingsConfig.Endpoint), new AzureCliCredential())\n                .GetEmbeddingClient(appConfig.AzureOpenAIEmbeddingsConfig.DeploymentName)\n                .AsIEmbeddingGenerator());\n        break;\n    case \"OpenAIEmbeddings\":\n        builder.Services.AddSingleton<IEmbeddingGenerator>(\n            sp => new OpenAIClient(appConfig.OpenAIEmbeddingsConfig.ApiKey)\n                .GetEmbeddingClient(appConfig.OpenAIEmbeddingsConfig.ModelId)\n                .AsIEmbeddingGenerator());\n        break;\n    default:\n        throw new NotSupportedException($\"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.\");\n}\n\n// Add the configured vector store record collection type to the\n// dependency injection container.\nswitch (appConfig.RagConfig.VectorStoreType)\n{\n    case \"AzureAISearch\":\n        kernelBuilder.Services.AddAzureAISearchCollection<TextSnippet<string>>(\n            appConfig.RagConfig.CollectionName,\n            new Uri(appConfig.AzureAISearchConfig.Endpoint),\n            new AzureKeyCredential(appConfig.AzureAISearchConfig.ApiKey));\n        break;\n    case \"CosmosMongoDB\":\n        kernelBuilder.Services.AddCosmosMongoCollection<TextSnippet<string>>(\n            appConfig.RagConfig.CollectionName,\n            appConfig.CosmosMongoConfig.ConnectionString,\n            appConfig.CosmosMongoConfig.DatabaseName);\n        break;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/Demos/VectorStoreRAG/Program.cs#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set RagConfig:AIEmbeddingService to exactly 'AzureOpenAIEmbeddings' or 'OpenAIEmbeddings' in your configuration source.","Add a new case arm for additional embedding providers if needed.","Verify AIChatService and AIEmbeddingService are set to compatible, distinct values.","Add startup validation that lists the supported values in the error message."],"exampleFix":"// before\ndefault:\n    throw new NotSupportedException($\"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported.\");\n\n// after — list valid values in the error\ndefault:\n    throw new NotSupportedException(\n        $\"AI Embedding Service type '{appConfig.RagConfig.AIEmbeddingService}' is not supported. \" +\n        \"Valid values: 'AzureOpenAIEmbeddings', 'OpenAIEmbeddings'.\");","handlingStrategy":"validation","validationCode":"var validEmbeddingServices = new[] { \"AzureOpenAIEmbeddings\", \"OpenAIEmbeddings\" };\nif (!validEmbeddingServices.Contains(appConfig.RagConfig.AIEmbeddingService))\n    throw new ArgumentException($\"AIEmbeddingService must be one of: {string.Join(\", \", validEmbeddingServices)}. Got: '{appConfig.RagConfig.AIEmbeddingService}'\");","typeGuard":"bool IsValidEmbeddingService(string? s) => s is \"AzureOpenAIEmbeddings\" or \"OpenAIEmbeddings\";","tryCatchPattern":null,"preventionTips":["Validate all configuration switch-values at startup before the switch statement.","Keep the valid-values list in a shared constant to avoid drift.","Ensure AIChatService and AIEmbeddingService are set to compatible providers."],"tags":["configuration","not-supported","rag","vector-store","embeddings","startup"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}