Esempio n. 1
0
        /// <summary>
        /// CopyToContainer content of an Azure blob container
        /// </summary>
        /// <param name="containerName"></param>
        /// <param name="sourceClient"></param>
        /// <param name="targetClient"></param>
        /// <returns></returns>
        public static async Task CopyContainerByName(this CloudBlobClient sourceClient, string containerName,
                                                     CloudBlobClient targetClient)
        {
            var targetContainer = await targetClient.CreateContainerIfNotExists(containerName);

            await Task.WhenAll((await
                                sourceClient
                                .GetContainerReference(containerName)
                                .ListBlobsSegmentedAsync(new BlobContinuationToken()))
                               .Results
                               .Select(blob =>
                                       new CloudBlockBlob(blob.Uri, sourceClient.Credentials).CopyToContainer(targetContainer)).ToArray());
        }