Ejemplo n.º 1
0
        public async Task DeleteTables(DataCleanupParameters parameters)
        {
            _log.LogDebug("Table deletion starting.");

            try
            {
                CloudTableClient  tableClient    = _tableManager.CreateCloudTableClient(parameters.StorageConnectionString);
                List <CloudTable> cloudTableList = await _tableManager.GetTableListAsync(tableClient);

                var tableDeleteTasks = new List <Task>();
                if (cloudTableList != null)
                {
                    foreach (CloudTable table in cloudTableList)
                    {
                        tableDeleteTasks.Add(_tableManager.DeleteIfExists(table));
                    }
                    await Task.WhenAll(tableDeleteTasks);
                }

                _log.LogDebug($"Table deletion completed! Removed {tableDeleteTasks.Count} tables.");
            }
            catch (Exception ex)
            {
                _log.LogError(ex, "Exception encountered in DeleteTables method.");
                throw;
            }

            return;
        }