Beispiel #1
0
        /// <summary>
        /// Start copying all the blobs using BlobCopy API.
        /// Will break it into batches.
        /// </summary>
        /// <param name="origBlobList"></param>
        /// <param name="destinationUrl"></param>
        /// <param name="destBlobType"></param>
        public static void StartCopyList(IEnumerable <BasicBlobContainer> origBlobList, string destinationUrl, DestinationBlobType destBlobType, bool debugMode, bool skipIfExists)
        {
            var blobCopyDataList = new List <BlobCopyData>();

            var count = 0;

            // break into batches
            foreach (var blob in origBlobList)
            {
                try
                {
                    Console.WriteLine("Copy blob " + blob.DisplayName);
                    var bcd = AzureBlobCopyHandler.StartCopy(blob, destinationUrl, destBlobType, skipIfExists);
                    if (bcd != null)
                    {
                        Console.WriteLine("BlobCopy ID " + bcd.CopyID);
                        blobCopyDataList.Add(bcd);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Unable to start copying " + blob.DisplayName);
                    if (debugMode)
                    {
                        Console.WriteLine("Exception " + ex.ToString());
                    }
                }

                count++;

                if (count > blobCopyBatchSize)
                {
                    Console.WriteLine("New Batch");
                    // if blob copy and monitoring
                    if (ConfigHelper.MonitorBlobCopy)
                    {
                        AzureBlobCopyHandler.MonitorBlobCopy(destinationUrl);
                    }

                    count = 0;
                }
            }

            if (count > 0)
            {
                // if blob copy and monitoring
                if (ConfigHelper.MonitorBlobCopy)
                {
                    Console.WriteLine("New Batch");
                    AzureBlobCopyHandler.MonitorBlobCopy(destinationUrl);
                }
            }
        }
        /// <summary>
        /// Start copying all the blobs using BlobCopy API.
        /// Will break it into batches.
        /// </summary>
        /// <param name="origBlobList"></param>
        /// <param name="destinationUrl"></param>
        /// <param name="destBlobType"></param>
        public static void StartCopyList(IEnumerable <BasicBlobContainer> origBlobList, string destinationUrl, DestinationBlobType destBlobType)
        {
            var blobCopyDataList = new List <BlobCopyData>();

            var count = 0;

            // break into batches
            foreach (var blob in origBlobList)
            {
                Console.WriteLine("Copy blob " + blob.DisplayName);
                var bcd = AzureBlobCopyHandler.StartCopy(blob, destinationUrl, destBlobType);
                Console.WriteLine("BlobCopy ID " + bcd.CopyID);
                blobCopyDataList.Add(bcd);

                count++;

                if (count > blobCopyBatchSize)
                {
                    Console.WriteLine("New Batch");
                    // if blob copy and monitoring
                    if (ConfigHelper.MonitorBlobCopy)
                    {
                        AzureBlobCopyHandler.MonitorBlobCopy(destinationUrl);
                    }

                    count = 0;
                }
            }

            if (count > 0)
            {
                // if blob copy and monitoring
                if (ConfigHelper.MonitorBlobCopy)
                {
                    Console.WriteLine("New Batch");
                    AzureBlobCopyHandler.MonitorBlobCopy(destinationUrl);
                }
            }
        }