public static IServiceCollection AddCosmosDb(this IServiceCollection services, Action <CosmosDbClientBuilder> configure = null)
        {
            services.TryAddSingleton <ICosmosDbContainerFactory, CosmosDbContainerFactory>();

            services.AddSingleton <CosmosDbClientBuilder>(provider =>
            {
                CosmosDbClientBuilder clientBuilder = new CosmosDbClientBuilder(services);

                configure?.Invoke(clientBuilder);

                return(clientBuilder);
            });

            services.AddSingleton <ICosmosDbClient>(provider => provider.GetRequiredService <CosmosDbClientBuilder>().Build());

            return(services);
        }
        public static IServiceCollection AddCosmosDb(this IServiceCollection services, Action <CosmosDbClientBuilder> configure = null)
        {
            services.AddTransient(provider =>
            {
                var config           = provider.GetRequiredService <IConfiguration>();
                var containerFactory = provider.GetService <ICosmosDbContainerFactory>();

                CosmosDbClientBuilder builder = new CosmosDbClientBuilder()
                                                .ReadConfiguration(config);

                builder.WithContainerFactory(containerFactory);

                configure?.Invoke(builder);

                return(builder);
            });

            services.AddSingleton <ICosmosDbClient>(provider => provider.GetRequiredService <CosmosDbClientBuilder>().Build());

            return(services);
        }