public static CloudBlobContainer GetContainer(string connectionString, string containerName)
        {
            try
            {
                return(BackupRestoreUtility.PerformWithRetries <string, CloudBlobContainer>(
                           (string name) =>
                {
                    CloudBlobContainer container = GetContainerRef(connectionString, name);

                    // Create the container
                    if (!container.Exists())
                    {
                        throw new ArgumentException(string.Format("Given container {0} doesn't exist.", name), "containerName");
                    }

                    return container;
                },
                           containerName,
                           new RetriableOperationExceptionHandler(AzureStorageExceptionHandler),
                           RetryCount));
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to get container {0} from Azure storage.",
                    containerName);

                throw;
            }
        }
        public static BlobResultSegment GetBlobList(CloudBlobDirectory directory, bool useFlatBlobListing, BlobContinuationToken blobContinuationToken, int maxResults)
        {
            try
            {
                return(BackupRestoreUtility.PerformWithRetries <bool, BlobResultSegment>(
                           (bool flatBlobListing) =>
                {
                    return directory.ListBlobsSegmented(flatBlobListing, BlobListingDetails.None, maxResults, blobContinuationToken, null, null);
                },
                           useFlatBlobListing,
                           new RetriableOperationExceptionHandler(AzureStorageExceptionHandler),
                           RetryCount));
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to list blobs under directory {0} from Azure storage.",
                    directory.Prefix);

                throw;
            }
        }
        public static CloudBlockBlob GetCloudBlockBlobRef(CloudBlobContainer container, string blockBlobPath)
        {
            try
            {
                return(BackupRestoreUtility.PerformWithRetries <string, CloudBlockBlob>(
                           (string blobPath) =>
                {
                    return container.GetBlockBlobReference(blobPath);
                },
                           blockBlobPath,
                           new RetriableOperationExceptionHandler(AzureStorageExceptionHandler),
                           RetryCount));
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to get block blob reference {0} from Azure storage container.",
                    blockBlobPath);

                throw;
            }
        }
        public static IEnumerable <IListBlobItem> GetBlobList(CloudBlobDirectory directory, bool useFlatBlobListing)
        {
            try
            {
                return(BackupRestoreUtility.PerformWithRetries <bool, IEnumerable <IListBlobItem> >(
                           (bool flatBlobListing) =>
                {
                    return directory.ListBlobs(flatBlobListing);
                },
                           useFlatBlobListing,
                           new RetriableOperationExceptionHandler(AzureStorageExceptionHandler),
                           RetryCount));
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to list blobs under directory {0} from Azure storage.",
                    directory.Prefix);

                throw;
            }
        }
        public static CloudBlobDirectory GetCloudBlobDirectoryRef(CloudBlobContainer container, string directoryPath)
        {
            try
            {
                return(BackupRestoreUtility.PerformWithRetries <string, CloudBlobDirectory>(
                           (string relDirName) =>
                {
                    return container.GetDirectoryReference(relDirName);
                },
                           directoryPath,
                           new RetriableOperationExceptionHandler(AzureStorageExceptionHandler),
                           RetryCount));
            }
            catch (Exception e)
            {
                TraceSource.WriteExceptionAsError(
                    TraceType,
                    e,
                    "Failed to get directory reference {0} from Azure storage.",
                    directoryPath);

                throw;
            }
        }