コード例 #1
0
        public async Task SaveTableSnapshotAsync(DbTable dbTable)
        {
            var container = await _storageAccount.GetBlockBlobReferenceAsync(dbTable.Name);

            if (container == null)
            {
                Console.WriteLine($"{DateTime.UtcNow:s} Skipped synchronizing table: {dbTable.Name}");
                return;
            }

            await container.CleanContainerAsync();

            Console.WriteLine($"{DateTime.UtcNow:s} Container cleaned: {dbTable.Name}");

            var partitions = dbTable.GetAllPartitions();

            foreach (var dbPartition in partitions)
            {
                var data = dbPartition.GetAllRows().ToJsonArray().AsArray();
                await container.SavePartitionAsync(dbPartition.PartitionKey, data);

                Console.WriteLine($"{DateTime.UtcNow:s} Saved snapshot: {dbTable.Name}/{dbPartition.PartitionKey}");
            }
        }