public static CosmosDbConfiguration CreateValidConfiguration( string endpoint, string key, string throughputConfigValue) { var config = new CosmosDbConfiguration { Endpoint = new Uri(endpoint) }; if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException("key", "CosmosDb requires an access key"); } config.Key = key; int throughputActualValue; if (int.TryParse(throughputConfigValue, out throughputActualValue)) { config.Throughput = throughputActualValue < 400 ? 400 : throughputActualValue; } else { config.Throughput = 400; } return(config); }
public CosmosWriteOperations(DbLocation dataLocation, CosmosDbConfiguration cosmosDbConfiguration) { this.dataLocation = dataLocation; this.cosmosDbConfiguration = cosmosDbConfiguration; this.documentClient = new DocumentClient(cosmosDbConfiguration.Endpoint, cosmosDbConfiguration.Key, new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp, MaxConnectionLimit = 1000 }); this.documentClient.OpenAsync(); // initialise the client, and ensure all routes are pre-fetched. }
public CosmosWriteOperations(DbLocation dataLocation, CosmosDbConfiguration cosmosDbConfiguration) { this.dataLocation = dataLocation; this.cosmosDbConfiguration = cosmosDbConfiguration; string connectionString = @"mongodb://*****:*****@cosmosdb-wu2-prod1.documents.azure.com:10255/?ssl=true&replicaSet=globaldb"; //string connectionString = @"mongodb://*****:*****@localhost:27017"; MongoClientSettings settings = MongoClientSettings.FromUrl( new MongoUrl(connectionString) ); settings.SslSettings = new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 }; this.documentClient = new MongoClient(settings); }