{"record":{"id":"179a58f612b6ab66","repo":"dotnet/orleans","slug":"configuration-for-azure-cosmos-db-provider-name","errorCode":null,"errorMessage":"Configuration for Azure Cosmos DB provider {_name} is invalid. CosmosOptions.DatabaseName is not valid.","messagePattern":"Configuration for Azure Cosmos DB provider (.+?) is invalid\\. CosmosOptions\\.DatabaseName is not valid\\.","errorType":"validation","errorClass":"OrleansConfigurationException","httpStatus":null,"severity":"critical","filePath":"src/Azure/Shared/Cosmos/CosmosOptionsValidator.cs","lineNumber":39,"sourceCode":"    private readonly TOptions _options;\n    private readonly string _name;\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"CosmosOptionsValidator{TOptions}\"/> type.\n    /// </summary>\n    /// <param name=\"options\">The instance to be validated.</param>\n    /// <param name=\"name\">The option name to be validated.</param>\n    public CosmosOptionsValidator(TOptions options, string name)\n    {\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":21,"sourceCodeEnd":52,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Cosmos/CosmosOptionsValidator.cs#L21-L52","documentation":"Thrown by CosmosOptionsValidator.ValidateConfiguration at startup when CosmosOptions.DatabaseName is null, empty, or whitespace. The Cosmos provider must target a specific database.","triggerScenarios":"Configuring a Cosmos-backed grain storage or streaming provider without setting DatabaseName.","commonSituations":"Missing DatabaseName key in appsettings; wrong config binding; copy-paste from a sample that omits it.","solutions":["Set options.DatabaseName to a non-empty database name.","Verify the configuration section binding includes the DatabaseName key.","Confirm the database exists in the Cosmos account."],"exampleFix":"// before\n// config: { \"ContainerName\": \"grainState\" } // no DatabaseName\n\n// after\n// config: { \"DatabaseName\": \"Orleans\", \"ContainerName\": \"grainState\" }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(options.DatabaseName))\n    throw new OrleansConfigurationException(\"DatabaseName required\");","typeGuard":"static bool HasDatabaseName(CosmosOptions o) => !string.IsNullOrWhiteSpace(o.DatabaseName);","tryCatchPattern":null,"preventionTips":["Include DatabaseName in every Cosmos provider configuration section.","Validate option values in a startup filter."],"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"}