예제 #1
0
        public CosmosDBThrottledGate(string cosmosDbConnectionString, string databaseName, string containerName)
        {
            var cosmosClient = new Microsoft.Azure.Cosmos.CosmosClient(cosmosDbConnectionString);
            var db           = cosmosClient.GetDatabase(databaseName);

            this.container = db.GetContainer(containerName);
        }
예제 #2
0
        /// <summary>
        /// Creates a Cosmos DB database and a container with the specified partition key.
        /// This will be used to pull the FlowCal repo information
        /// </summary>
        /// <returns></returns>
        private static async Task <ICosmosService> InitializeCosmosClientInstanceAsync(IConfigurationSection configurationSection)
        {
            string         databaseName  = configurationSection.GetSection("DatabaseName").Value;
            string         containerName = configurationSection.GetSection("ContainerName").Value;
            string         account       = configurationSection.GetSection("Account").Value;
            string         key           = configurationSection.GetSection("Key").Value;
            CosmosClient   client        = new Microsoft.Azure.Cosmos.CosmosClient(account, key);
            ICosmosService cosmosService = new CosmosService(client, databaseName, containerName);

            Microsoft.Azure.Cosmos.DatabaseResponse database = await client.CreateDatabaseIfNotExistsAsync(databaseName);

            await database.Database.CreateContainerIfNotExistsAsync(containerName, "/appName");

            return(cosmosService);
        }
예제 #3
0
        public async Task OneTimeSetUp()
        {
            TestSetUp.Reset(false);

            _config = AgentTester.Configuration.GetSection("CosmosDb");
            var cc = new Cosmos.CosmosClient(_config.GetValue <string>("EndPoint"), _config.GetValue <string>("AuthKey"));

            _csu = await CosmosDbContainerSetUp.ReplaceAndOpenAsync(cc, _config.GetValue <string>("Database"),
                                                                    new Cosmos.ContainerProperties
            {
                Id = "Items",
                PartitionKeyPath = "/_partitionKey",
                UniqueKeyPolicy  = new Cosmos.UniqueKeyPolicy {
                    UniqueKeys = { new Cosmos.UniqueKey {
                                       Paths =          { "/serialNo"}
                                   } }
                }
            }, 400);

            await _csu.ImportBatchAsync <RobotTest, Robot>("Data.yaml", "items");
        }
예제 #4
0
 protected internal CosmosDatabasesCore(CosmosClient client)
 {
     this.client         = client;
     this.databasesCache = new ConcurrentDictionary <string, CosmosDatabase>();
 }
 /// <summary>
 /// Create a <see cref="CosmosContainers"/>
 /// </summary>
 /// <param name="database">The <see cref="CosmosDatabase"/> the container set is related to.</param>
 protected internal CosmosContainers(CosmosDatabase database)
 {
     this.database       = database;
     this.client         = database.Client;
     this.containerCache = new ConcurrentDictionary <string, CosmosContainer>();
 }
 /// <summary>
 /// Create a <see cref="CosmosUserDefinedFunctions"/>
 /// </summary>
 /// <param name="container">The <see cref="CosmosContainer"/> the user defined function set is related to.</param>
 protected internal CosmosUserDefinedFunctions(CosmosContainer container)
 {
     this.container = container;
     this.client    = container.Client;
 }