public async Task CollectGarbage_Explicit() { // Get all of our configs var configs = new List <TenantConfiguration>(); try { configs.Add(TestConfigurations.DefaultTargetTenant); } catch (InconclusiveException) { } try { configs.Add(TestConfigurations.DefaultSecondaryTargetTenant); } catch (InconclusiveException) { } try { configs.Add(TestConfigurations.DefaultTargetPremiumBlobTenant); } catch (InconclusiveException) { } try { configs.Add(TestConfigurations.DefaultTargetPreviewBlobTenant); } catch (InconclusiveException) { } try { configs.Add(TestConfigurations.DefaultTargetOAuthTenant); } catch (InconclusiveException) { } foreach (TenantConfiguration config in configs) { // Blobs var blobs = new BlobServiceClient(config.ConnectionString); await foreach (Response <ContainerItem> container in blobs.GetContainersAsync()) { try { await blobs.DeleteBlobContainerAsync(container.Value.Name); } catch (StorageRequestFailedException ex) when(ex.ErrorCode == BlobErrorCode.LeaseIdMissing) { // Break any lingering leases await blobs.GetBlobContainerClient(container.Value.Name).GetLeaseClient().BreakAsync(); } catch (StorageRequestFailedException ex) when(ex.ErrorCode == BlobErrorCode.ContainerBeingDeleted) { // Ignore anything already being deleted } } // Queues var queues = new QueueServiceClient(config.ConnectionString); await foreach (Response <QueueItem> queue in queues.GetQueuesAsync()) { try { await queues.DeleteQueueAsync(queue.Value.Name); } catch (StorageRequestFailedException ex) when(ex.ErrorCode == QueueErrorCode.QueueBeingDeleted) { // Ignore anything already being deleted } } // Files var files = new FileServiceClient(config.ConnectionString); await foreach (Response <ShareItem> share in files.GetSharesAsync()) { try { await files.DeleteShareAsync(share.Value.Name); } catch (StorageRequestFailedException ex) when(ex.ErrorCode == FileErrorCode.ShareBeingDeleted) { // Ignore anything already being deleted } } } }