Esempio n. 1
0
        private bool CopyFileToDestination(CloudBlockBlob blob, string destinationFullFileName, int retryCount)
        {
            CloudFileCopyInfo cloudFileCopyInfo = new CloudFileCopyInfo()
            {
                SourceBlob   = blob,
                FullFileName = destinationFullFileName,
                RetryCount   = retryCount
            };

            try
            {
                BackupRestoreUtility.PerformWithRetries(
                    this.CopyBlobToDestinationFile,
                    cloudFileCopyInfo,
                    new RetriableOperationExceptionHandler(this.AzureStorageExceptionHandler),
                    this.retryCount);
            }
            catch (Exception e)
            {
                this.TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to copy blob: {0} to file: {1}.",
                    blob.Name,
                    destinationFullFileName);

                throw;
            }

            return(true);
        }
Esempio n. 2
0
        private void CopyBlobToDestinationFile(object context)
        {
            CloudFileCopyInfo fileCopyInfo = (CloudFileCopyInfo)context;
            string            directory    = Path.GetDirectoryName(fileCopyInfo.FullFileName);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            fileCopyInfo.SourceBlob.DownloadToFile(fileCopyInfo.FullFileName, FileMode.Create);
        }