public DocumentClient GetSampleDocumentDbClient()
 {
     try
     {
         var    SourceCosmosDBSettings = CloneSettings.GetConfigurationSection("SampleCosmosDBSettings");
         string SourceEndpointUrl      = SourceCosmosDBSettings["EndpointUrl"];
         string SourceAccessKey        = SourceCosmosDBSettings["AccessKey"];
         var    sourceDocumentClient   = new DocumentClient(new Uri(SourceEndpointUrl), SourceAccessKey, ConnectionPolicy);
         return(sourceDocumentClient);
     }
     catch (Exception ex)
     {
         logger.LogError(ex);
         throw;
     }
 }
        //private EntitySummary summary;

        #endregion

        public CodeMigrator()
        {
            //initialize settings and other utilities
            var SourceCosmosDBSettings = CloneSettings.GetConfigurationSection("SourceCosmosDBSettings");

            SourceEndpointUrl    = CloneSettings.SourceSettings.EndpointUrl;;
            SourceAccessKey      = CloneSettings.SourceSettings.AccessKey;
            sourceDatabaseName   = CloneSettings.SourceSettings.DatabaseName;
            sourceCollectionName = CloneSettings.SourceSettings.CollectionName;

            //var TargetCosmosDBSettings = CloneSettings.GetConfigurationSection("TargetCosmosDBSettings");
            TargetEndpointUrl    = CloneSettings.TargetSettings.EndpointUrl;
            TargetAccessKey      = CloneSettings.TargetSettings.AccessKey;
            TargetDatabaseName   = CloneSettings.TargetSettings.DatabaseName;
            TargetCollectionName = CloneSettings.TargetSettings.CollectionName;

            cosmosHelper       = new CosmosDBHelper();
            cosmosBulkImporter = new CosmosBulkImporter();
            //summary = new EntitySummary();
            //summary.EntityType = "DBCode";
        }
        public async Task <DocumentCollection> CreateSampleDocumentCollection(DocumentClient sampleClient, bool IsFixedCollection = false)
        {
            try
            {
                var    sampleCosmosDBSettings = CloneSettings.GetConfigurationSection("SampleCosmosDBSettings");
                string sampleDatabaseName     = sampleCosmosDBSettings["DatabaseName"];;
                string sampleCollectionName   = sampleCosmosDBSettings["CollectionName"];
                int    offerThroughput        = 1000;
                int.TryParse(sampleCosmosDBSettings["OfferThroughputRUs"], out offerThroughput);
                await sampleClient.CreateDatabaseIfNotExistsAsync(new Database { Id = sampleDatabaseName });

                DocumentCollection newDocumentCollection;
                if (!IsFixedCollection)
                {
                    var partitionKeyDefinition = new PartitionKeyDefinition();
                    partitionKeyDefinition.Paths.Add("/CompositeName");
                    newDocumentCollection = (DocumentCollection)await sampleClient.CreateDocumentCollectionIfNotExistsAsync
                                                (UriFactory.CreateDatabaseUri(sampleDatabaseName),
                                                new DocumentCollection { Id = sampleCollectionName, PartitionKey = partitionKeyDefinition },
                                                new RequestOptions { OfferThroughput = offerThroughput });
                }
                else
                {
                    //no partition key if it is a fixed collection
                    newDocumentCollection = (DocumentCollection)await sampleClient.CreateDocumentCollectionIfNotExistsAsync
                                                (UriFactory.CreateDatabaseUri(sampleDatabaseName),
                                                new DocumentCollection { Id = sampleCollectionName },
                                                new RequestOptions { OfferThroughput = offerThroughput });
                }
                return(newDocumentCollection);
            }
            catch (Exception ex)
            {
                logger.LogError(ex);
                throw;
            }
        }