コード例 #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
ファイル: RobotTest.cs プロジェクト: keithlemon/Beef
        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>();
 }
コード例 #5
0
 /// <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;
 }