{"record":{"id":"9d522d651e9af421","repo":"dotnet/orleans","slug":"configuration-for-azure-cosmos-db-provider-name-9d522d","errorCode":null,"errorMessage":"Configuration for Azure Cosmos DB provider {_name} is invalid. You must call ConfigureCosmosClient to configure access to Azure Cosmos DB.","messagePattern":"Configuration for Azure Cosmos DB provider (.+?) is invalid\\. You must call ConfigureCosmosClient to configure access to Azure Cosmos DB\\.","errorType":"validation","errorClass":"OrleansConfigurationException","httpStatus":null,"severity":"critical","filePath":"src/Azure/Shared/Cosmos/CosmosOptionsValidator.cs","lineNumber":48,"sourceCode":"    {\n        _options = options;\n        _name = name;\n    }\n\n    /// <inheritdoc/>\n    public void ValidateConfiguration()\n    {\n        if (string.IsNullOrWhiteSpace(_options.DatabaseName))\n            throw new OrleansConfigurationException(\n                $\"Configuration for Azure Cosmos DB provider {_name} is invalid. {nameof(_options.DatabaseName)} is not valid.\");\n\n        if (string.IsNullOrWhiteSpace(_options.ContainerName))\n            throw new OrleansConfigurationException(\n                $\"Configuration for Azure Cosmos DB provider {_name} is invalid. {nameof(_options.ContainerName)} is not valid.\");\n\n        if (_options.CreateClient is null)\n        {\n            throw new OrleansConfigurationException(\n                $\"Configuration for Azure Cosmos DB provider {_name} is invalid. You must call {nameof(_options.ConfigureCosmosClient)} to configure access to Azure Cosmos DB.\");\n        }\n    }\n}","sourceCodeStart":30,"sourceCodeEnd":52,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Cosmos/CosmosOptionsValidator.cs#L30-L52","documentation":"Thrown by CosmosOptionsValidator.ValidateConfiguration at startup when CosmosOptions.CreateClient is null, meaning ConfigureCosmosClient was never called. The provider cannot reach Cosmos without a client factory.","triggerScenarios":"Registering a Cosmos provider but omitting the .ConfigureCosmosClient(...) call.","commonSituations":"Following a partial sample; refactor that removed the client configuration; switching from connection-string to credential-based client without adding the configure call.","solutions":["Call options.ConfigureCosmosClient(endpoint, authKeyOrResourceToken) or the delegate overload.","Verify the configure call is on the options instance/name that the validator checks.","If using TokenCredential, use the delegate overload to build the CosmosClient with the credential."],"exampleFix":"// before\n// no ConfigureCosmosClient call\n\n// after\noptions.ConfigureCosmosClient(endpoint, authKey);\n// or\noptions.ConfigureCosmosClient(sp => new(new CosmosClient(endpoint, tokenCredential, options.ClientOptions)));","handlingStrategy":"validation","validationCode":"if (options.CreateClient is null)\n    throw new OrleansConfigurationException(\"Call ConfigureCosmosClient before startup\");","typeGuard":"static bool IsConfigured(CosmosOptions o) => o.CreateClient is not null;","tryCatchPattern":null,"preventionTips":["Centralize Cosmos provider configuration in a helper that always calls ConfigureCosmosClient.","Add a boot test that starts the client to catch misconfiguration."],"tags":["cosmos","configuration","startup","azure","validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}