Ejemplo n.º 1
0
        public static IServiceCollection AddCosmosDb(this IServiceCollection services,
                                                     string endpointUrl,
                                                     string primaryKey,
                                                     string databaseName,
                                                     List <ContainerInfo> containers)
        {
            CosmosClient client = new CosmosClient(endpointUrl, primaryKey);
            var          cosmosDbClientFactory = new CosmosDbContainerFactory(client, databaseName, containers);

            services.AddSingleton <ICosmosDbContainerFactory>(cosmosDbClientFactory);

            return(services);
        }
Ejemplo n.º 2
0
        public static IServiceCollection AddCosmosDb(this IServiceCollection services,
                                                     string endpointUrl,
                                                     string primaryKey,
                                                     string databaseName,
                                                     List <ContainerInfo> containers)
        {
            if (endpointUrl == null || primaryKey == null || databaseName == null)
            {
                // allow server to be started up without these settings
                // in case they're just trying to seed their environment
                // in the future we'll remove this in favor of centralized seeding capability
                return(services);
            }
            CosmosClient client = new CosmosClient(endpointUrl, primaryKey);
            var          cosmosDbClientFactory = new CosmosDbContainerFactory(client, databaseName, containers);

            services.AddSingleton <ICosmosDbContainerFactory>(cosmosDbClientFactory);

            return(services);
        }