public async System.Threading.Tasks.Task <SoftmakeAll.SDK.OperationResult> CopyAsync(System.String SourceContainerName, System.String[] SourceStorageFileNames, System.String TargetContainerName, System.String[] TargetStorageFileNames, System.Boolean Overwrite) { SoftmakeAll.SDK.CloudStorage.Azure.Environment.Validate(); SoftmakeAll.SDK.OperationResult OperationResult = new SoftmakeAll.SDK.OperationResult(); if ((System.String.IsNullOrWhiteSpace(SourceContainerName)) || (SourceStorageFileNames == null) || (SourceStorageFileNames.Length == 0) || (System.String.IsNullOrWhiteSpace(TargetContainerName)) || (TargetStorageFileNames == null) || (TargetStorageFileNames.Length == 0)) { OperationResult.Message = "The SourceContainerName, SourceStorageFileNames, TargetContainerName and TargetStorageFileNames cannot be null."; return(OperationResult); } if (SourceStorageFileNames.Length != TargetStorageFileNames.Length) { OperationResult.Message = "The SourceStorageFileNames and TargetStorageFileNames must be the same length."; return(OperationResult); } try { global::Azure.Storage.Blobs.BlobContainerClient SourceBlobContainerClient = new global::Azure.Storage.Blobs.BlobContainerClient(SoftmakeAll.SDK.CloudStorage.Azure.Environment._ConnectionString, SourceContainerName); global::Azure.Storage.Blobs.BlobContainerClient TargetBlobContainerClient; if (SourceContainerName != TargetContainerName) { TargetBlobContainerClient = new global::Azure.Storage.Blobs.BlobContainerClient(SoftmakeAll.SDK.CloudStorage.Azure.Environment._ConnectionString, TargetContainerName); } else { TargetBlobContainerClient = SourceBlobContainerClient; } using (System.Threading.SemaphoreSlim SemaphoreSlim = new System.Threading.SemaphoreSlim(SourceStorageFileNames.Length)) { System.Collections.Generic.List <System.Threading.Tasks.Task> CopyTasks = new System.Collections.Generic.List <System.Threading.Tasks.Task>(); for (System.Int32 i = 0; i < SourceStorageFileNames.Length; i++) { System.String SourceStorageFileName = SourceStorageFileNames[i]; global::Azure.Storage.Blobs.BlobClient SourceBlobClient = SourceBlobContainerClient.GetBlobClient(SourceStorageFileName); if (!(await SourceBlobClient.ExistsAsync())) { continue; } System.String TargetStorageFileName = TargetStorageFileNames[i]; global::Azure.Storage.Blobs.BlobClient TargetBlobClient = TargetBlobContainerClient.GetBlobClient(TargetStorageFileName); if ((!(Overwrite)) && (await TargetBlobClient.ExistsAsync())) { continue; } await SemaphoreSlim.WaitAsync(); CopyTasks.Add(System.Threading.Tasks.Task.Run(async() => { await TargetBlobClient.StartCopyFromUriAsync(SourceBlobClient.Uri); SemaphoreSlim.Release(); })); } if (CopyTasks.Any()) { await System.Threading.Tasks.Task.WhenAll(CopyTasks); } } } catch (System.Exception ex) { OperationResult.Message = ex.Message; return(OperationResult); } OperationResult.ExitCode = 0; return(OperationResult); }