コード例 #1
0
        /// <summary>
        /// Get blog info by url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public virtual BlobInfo GetBlobInfo(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException(nameof(url));
            }

            var      uri    = url.IsAbsoluteUrl() ? new Uri(url) : new Uri(_cloudBlobClient.BaseUri, url.TrimStart('/'));
            BlobInfo retVal = null;

            try
            {
                var cloudBlob = _cloudBlobClient.GetBlobReferenceFromServer(uri);
                retVal = new BlobInfo
                {
                    Url          = Uri.EscapeUriString(cloudBlob.Uri.ToString()),
                    FileName     = Path.GetFileName(Uri.UnescapeDataString(cloudBlob.Uri.ToString())),
                    ContentType  = cloudBlob.Properties.ContentType,
                    Size         = cloudBlob.Properties.Length,
                    ModifiedDate = cloudBlob.Properties.LastModified?.DateTime,
                    RelativeUrl  = cloudBlob.Uri.LocalPath
                };
            }
            catch (Exception)
            {
                //Azure blob storage client does not provide method to check blob url exist without throwing exception
            }
            return(retVal);
        }
コード例 #2
0
        private static void DownloadTestVhdsAndPackages(string testEnvironment, string downloadDirectoryPath, string blobUri, string storageAccount, string storageKey)
        {
            StorageCredentials credentials = new StorageCredentials(storageAccount, storageKey);
            CloudBlobClient    blobClient  = new CloudBlobClient(new Uri(blobUri), credentials);

            blobContainer = blobClient.GetContainerReference(VhdFilesContainerName);
            foreach (IListBlobItem blobItem in blobContainer.ListBlobs())
            {
                ICloudBlob blob = blobClient.GetBlobReferenceFromServer(blobItem.Uri);
                Console.WriteLine("Downloading file {0} from blob Uri {1}", blob.Name, blob.Uri);
                FileStream blobStream = new FileStream(Path.Combine(downloadDirectoryPath, blob.Name), FileMode.Create);
                blob.DownloadToStream(blobStream);
                blobStream.Flush();
                blobStream.Close();
            }

            blobContainer = blobClient.GetContainerReference(toolsContainerName);
            foreach (IListBlobItem blobItem in blobContainer.ListBlobs())
            {
                ICloudBlob blob = blobClient.GetBlobReferenceFromServer(blobItem.Uri);
                Console.WriteLine("Downloading file {0} from blob Uri {1}", blob.Name, blob.Uri);
                FileStream blobStream = new FileStream(Path.Combine(downloadDirectoryPath, @"..\..\", blob.Name), FileMode.Create);
                blob.DownloadToStream(blobStream);
                blobStream.Flush();
                blobStream.Close();
            }
        }
コード例 #3
0
 // DeleteFile tries to delete the corresponding blob and ensures the parent directory is tracked as empty.
 public NtStatus DeleteFile(string fileName, DokanFileInfo info)
 {
     try
     {
         var blob = blobs.GetBlobReferenceFromServer(blobs.ListBlobs(fileName.Trim('\\')).First().StorageUri);
         blob.Delete();
         if (!blobs.ListBlobs(Path.GetDirectoryName(fileName).Trim('\\').Replace('\\', '/')).Any())
         {
             AddEmptyDirectories(Path.GetDirectoryName(fileName));
         }
         return(DokanResult.Success);
     }
     catch { return(DokanResult.Error); }
 }
コード例 #4
0
        public void NonExistingObject()
        {
            AllVariations <string>(target =>
            {
                Assert.IsTrue(blobClient.GetBlobReferenceFromServer(target.BackingBlobUri).Exists());
                Assert.IsNull(target.Object);
                target.Object = "Hello world!";
                Assert.AreEqual("Hello world!", target.Object);

                PauseForReplication();

                Assert.AreEqual("Hello world!", target.Object);
                Assert.IsTrue(blobClient.GetBlobReferenceFromServer(target.BackingBlobUri).Exists());
            });
        }
コード例 #5
0
ファイル: JSONFile.cs プロジェクト: CerebralUnit/cryptobuddy
        private T GetFromBlob(string fileName)
        {
            CloudStorageAccount StorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["BlobConnectionString"]);

            CloudBlobClient Client = StorageAccount.CreateCloudBlobClient();

            var URI = new Uri(BLOB_DATA_ROOT + fileName);

            var Blob = Client.GetBlobReferenceFromServer(URI);

            T result = default(T);

            using (var stream = new MemoryStream())
            {
                Blob.DownloadToStream(stream);
                stream.Position = 0;
                var serializer = new JsonSerializer();

                using (var sr = new StreamReader(stream))
                    using (var jsonTextReader = new JsonTextReader(sr))
                    {
                        result = serializer.Deserialize <T>(jsonTextReader);
                    }
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Start copy operation by source uri
        /// </summary>
        /// <param name="srcICloudBlob">Source uri</param>
        /// <param name="destContainer">Destinaion container name</param>
        /// <param name="destBlobName">Destination blob name</param>
        /// <returns>Destination ICloudBlob object</returns>
        private void StartCopyBlob(IStorageBlobManagement destChannel, string srcUri, string destContainer, string destBlobName, AzureStorageContext context)
        {
            if (context != null)
            {
                Uri sourceUri  = new Uri(srcUri);
                Uri contextUri = new Uri(context.BlobEndPoint);

                if (sourceUri.Host.ToLower() == contextUri.Host.ToLower())
                {
                    CloudBlobClient blobClient    = context.StorageAccount.CreateCloudBlobClient();
                    ICloudBlob      blobReference = blobClient.GetBlobReferenceFromServer(sourceUri);
                    StartCopyBlob(destChannel, blobReference, destContainer, destBlobName);
                }
                else
                {
                    WriteWarning(String.Format(Resources.StartCopySourceContextMismatch, srcUri, context.BlobEndPoint));
                }
            }
            else
            {
                CloudBlobContainer container     = destChannel.GetContainerReference(destContainer);
                Func <long, Task>  taskGenerator = (taskId) => StartCopyInTransferManager(taskId, destChannel, new Uri(srcUri), container, destBlobName);
                RunTask(taskGenerator);
            }
        }
コード例 #7
0
        public static string GetBlobSasUri(string filePath, string fileName)
        {
            CloudStorageAccount storageAccount =
                CloudStorageAccount.Parse(
                    ConfigurationManager.AppSettings["StorageConnectionString"]);
            CloudBlobClient    blobClient = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer container  = blobClient.GetContainerReference("poze");

            container.CreateIfNotExists();

            if (!container.GetPermissions().PublicAccess.Equals(BlobContainerPublicAccessType.Off))
            {
                container.SetPermissions(new BlobContainerPermissions
                {
                    PublicAccess = BlobContainerPublicAccessType.Off
                });
            }

            ICloudBlob blob = blobClient.GetBlobReferenceFromServer(new Uri(filePath));

            SharedAccessBlobPolicy sasConstraints =
                new SharedAccessBlobPolicy
            {
                SharedAccessStartTime  = DateTimeOffset.UtcNow.AddMinutes(-1),
                SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddHours(2),     // 2 hours expired
                Permissions            = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Write
            };


            string sasBlobToken = blob.GetSharedAccessSignature(sasConstraints);

            return(blob.Uri + sasBlobToken);
        }
コード例 #8
0
        public void DownloadFiles(string[] uris)
        {
            List <IListBlobItem> blobItems = new List <IListBlobItem>();

            foreach (string uri in uris)
            {
                try
                {
                    if (FileTypes.MapFileUriType(uri) != FileUriTypesEnum.azureStorageUri)
                    {
                        Log.Warning($"not blob storage path. skipping:{uri}");
                        continue;
                    }
                    else
                    {
                        blobItems.Add(_blobClient.GetBlobReferenceFromServer(new Uri(uri)));
                    }
                }
                catch (Exception e)
                {
                    Log.Exception($"{e}");
                }
            }

            QueueBlobSegmentDownload(blobItems);
            uris = blobItems.Select(x => x.Uri.ToString()).ToArray();

            Log.Info("waiting for download tasks");
            _blobTasks.Wait();
            _blobChildTasks.Wait();
        }
コード例 #9
0
        public virtual string ReadConfigurationFromBlob(
            IServiceManagement channel,
            string storageName,
            string subscriptionId,
            Uri configurationFileUri)
        {
            var storageService = channel.GetStorageKeys(subscriptionId, storageName);
            var storageKey     = storageService.StorageServiceKeys.Primary;

            storageService = channel.GetStorageService(subscriptionId, storageName);
            var blobStorageEndpoint = General.CreateHttpsEndpoint(
                storageService.StorageServiceProperties.Endpoints.Find(p => p.Contains(BlobEndpointIdentifier)));
            var           credentials   = new StorageCredentials(storageName, storageKey);
            var           client        = new CloudBlobClient(blobStorageEndpoint, credentials);
            ICloudBlob    blob          = client.GetBlobReferenceFromServer(configurationFileUri);
            StringBuilder configuration = new StringBuilder(string.Empty);

            using (var stream = blob.OpenRead())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        configuration.Append(reader.ReadLine());
                    }
                }
            }
            return(configuration.ToString());
        }
コード例 #10
0
        /// <summary>
        /// Check that blob or folder with passed path exist
        /// </summary>
        /// <param name="path">path /folder/blob.md</param>
        /// <returns></returns>
        public virtual bool PathExists(string path)
        {
            path = NormalizePath(path);

            var result = _cacheManager.Get("AzureBlobContentProvider.PathExists:" + path.GetHashCode(), "ContentRegion", () =>
            {
                // If requested path is a directory we should always return true because Azure blob storage does not support checking if directories exist
                var retVal = string.IsNullOrEmpty(Path.GetExtension(path));
                if (!retVal)
                {
                    var url = GetAbsoluteUrl(path);
                    try
                    {
                        retVal = _cloudBlobClient.GetBlobReferenceFromServer(new Uri(url)).Exists();
                    }
                    catch (Exception)
                    {
                        //Azure blob storage client does not provide method to check blob url exist without throwing exception
                    }
                }

                return((object)retVal);
            });

            return((bool)result);
        }
コード例 #11
0
        private CloudBlockBlob getBlob(Uri uri)
        {
            var             storageAccount = CloudStorageAccount.Parse(DocConstants.Get().ConnectionString);
            CloudBlobClient blobClient     = storageAccount.CreateCloudBlobClient();
            ICloudBlob      blob           = blobClient.GetBlobReferenceFromServer(uri);

            return(blob as CloudBlockBlob);
        }
コード例 #12
0
        public static string GetSasBlobUrl(string fileName)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
            CloudBlobClient     sasBlobClient  = new CloudBlobClient(storageAccount.BlobEndpoint, new StorageCredentials(SAS));
            CloudBlob           blob           = (CloudBlob)sasBlobClient.GetBlobReferenceFromServer(new Uri(fileName));

            return(blob.Uri.AbsoluteUri + SAS);
        }
コード例 #13
0
        public void DownloadFiles(List <string> uris)
        {
            List <IListBlobItem> blobItems = new List <IListBlobItem>();

            foreach (string uri in uris)
            {
                try
                {
                    blobItems.Add(_blobClient.GetBlobReferenceFromServer(new Uri(uri)));
                }
                catch (Exception e)
                {
                    Log.Exception($"{e}");
                }
            }

            QueueBlobSegmentDownload(blobItems);
        }
コード例 #14
0
        /// <summary>
        /// Get blog info by url
        /// </summary>
        /// <param name="blobUrl"></param>
        /// <returns></returns>
        public virtual BlobInfo GetBlobInfo(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }

            var uri       = url.IsAbsoluteUrl() ? new Uri(url) : new Uri(_cloudBlobClient.BaseUri, url.TrimStart('/'));
            var cloudBlob = _cloudBlobClient.GetBlobReferenceFromServer(uri);
            var retVal    = new BlobInfo
            {
                Url          = Uri.EscapeUriString(cloudBlob.Uri.ToString()),
                FileName     = Path.GetFileName(Uri.UnescapeDataString(cloudBlob.Uri.ToString())),
                ContentType  = cloudBlob.Properties.ContentType,
                Size         = cloudBlob.Properties.Length,
                ModifiedDate = cloudBlob.Properties.LastModified != null ? cloudBlob.Properties.LastModified.Value.DateTime : (DateTime?)null
            };

            return(retVal);
        }
コード例 #15
0
 public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
 {
     var storageService = channel.GetStorageKeys(subscriptionId, storageName);
     var storageKey = storageService.StorageServiceKeys.Primary;
     storageService = channel.GetStorageService(subscriptionId, storageName);
     var blobStorageEndpoint = new Uri(storageService.StorageServiceProperties.Endpoints.Find(p => p.Contains(BlobEndpointIdentifier)));
     var credentials = new StorageCredentials(storageName, storageKey);
     var client = new CloudBlobClient(blobStorageEndpoint, credentials);
     ICloudBlob blob = client.GetBlobReferenceFromServer(packageUri);
     blob.DeleteIfExists();
 }
コード例 #16
0
ファイル: ConfigManager.cs プロジェクト: lulzzz/pegasus2
        public List <Config> Read()
        {
            List <Config> list = null;

            Uri        uri  = new Uri(blobUriString);
            ICloudBlob blob = client.GetBlobReferenceFromServer(new StorageUri(uri));

            using (MemoryStream stream = new MemoryStream())
            {
                blob.DownloadToStream(stream);
                if (stream != null)
                {
                    stream.Position = 0;
                    byte[] data = stream.ToArray();
                    list = JsonConvert.DeserializeObject <List <Config> >(Encoding.UTF8.GetString(data));
                }
            }

            return(list);
        }
コード例 #17
0
        /// <summary>
        /// Get blob info by url
        /// </summary>
        /// <param name="blobUrl"></param>
        /// <returns></returns>
        public virtual BlobInfo GetBlobInfo(string blobUrl)
        {
            if (string.IsNullOrEmpty(blobUrl))
            {
                throw new ArgumentNullException(nameof(blobUrl));
            }
            var      uri    = blobUrl.IsAbsoluteUrl() ? new Uri(blobUrl) : new Uri(_cloudBlobClient.BaseUri, blobUrl.TrimStart('/'));
            BlobInfo retVal = null;

            try
            {
                var cloudBlob = _cloudBlobClient.GetBlobReferenceFromServer(uri);
                retVal = ConvertBlobToBlobInfo(cloudBlob);
            }
            catch (Exception)
            {
                //Azure blob storage client does not provide method to check blob url exist without throwing exception
            }
            return(retVal);
        }
コード例 #18
0
        public static void DeleteBlob(string account, string key, string blobUrl)
        {
            if (string.IsNullOrEmpty(blobUrl))
            {
                return;
            }

            CloudBlobClient blobClient = Client.GetBlobClient(account, key);
            ICloudBlob      blobRef    = blobClient.GetBlobReferenceFromServer(new Uri(blobUrl));

            blobRef.Delete();
        }
コード例 #19
0
        public string GetBlobSasUri(string blobUri, int hours)
        {
            var blob = blobClient.GetBlobReferenceFromServer(new Uri(blobUri));
            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();

            sasConstraints.SharedAccessStartTime  = DateTime.UtcNow.AddMinutes(-5);
            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(hours);
            sasConstraints.Permissions            = SharedAccessBlobPermissions.Read;
            string sasBlobToken = blob.GetSharedAccessSignature(sasConstraints);

            return(blob.Uri + sasBlobToken);
        }
コード例 #20
0
        public long GetBlobSize(string sharesAccessUriOfBlob)
        {
            Uri bloburi = new Uri(sharesAccessUriOfBlob);

            // CloudBlobClient clb = new CloudBlobClient(bloburi);

            var blobRefrence = _cloudBlobclient.GetBlobReferenceFromServer(bloburi);

            // blobRefrence.FetchAttributes();

            return(blobRefrence.Properties.Length);
        }
コード例 #21
0
        public void DeletePackageFromBlob(string storageName, Uri packageUri)
        {
            StorageAccountGetKeysResponse keys = StorageManagementClient.StorageAccounts.GetKeys(storageName);
            string     storageKey          = keys.PrimaryKey;
            var        storageService      = StorageManagementClient.StorageAccounts.Get(storageName);
            var        blobStorageEndpoint = storageService.StorageAccount.Properties.Endpoints[0];
            var        credentials         = new StorageCredentials(storageName, storageKey);
            var        client = new CloudBlobClient(blobStorageEndpoint, credentials);
            ICloudBlob blob   = client.GetBlobReferenceFromServer(packageUri);

            blob.DeleteIfExists();
        }
コード例 #22
0
        public static async Task <string> DownloadFileAsync(string location, CloudStorageAccount cloudAccount)
        {
            CloudBlobClient blobClient = cloudAccount.CreateCloudBlobClient();
            ICloudBlob      container  = blobClient.GetBlobReferenceFromServer(new Uri(location));

            using MemoryStream stream = new MemoryStream();
            await container.DownloadToStreamAsync(stream, CancellationToken.None);

            stream.Position           = 0;
            using StreamReader reader = new StreamReader(stream);
            return(await reader.ReadToEndAsync());
        }
コード例 #23
0
        /// <summary>
        /// Deletes the theme with the given name.
        /// </summary>
        /// <param name="themeName">The name of the theme to be deleted.</param>
        /// <returns><c>true</c> if the theme is removed, <c>false</c> otherwise.</returns>
        public bool DeleteTheme(string themeName)
        {
            var containerRef = _client.GetContainerReference(_wiki + "-themes");
            var directoryRef = containerRef.GetDirectoryReference(themeName);
            var blobs        = directoryRef.ListBlobs(useFlatBlobListing: true);

            foreach (var blob in blobs)
            {
                _client.GetBlobReferenceFromServer(blob.Uri).Delete(); // v.1.7: GetBlobReference(blob.Uri.AbsoluteUri)
            }
            return(true);
        }
コード例 #24
0
        public System.IO.Stream OpenReadOnly(string blobKey)
        {
            if (string.IsNullOrEmpty(blobKey))
            {
                throw new ArgumentNullException("blobKey");
            }

            System.IO.Stream retVal = null;
            var cloudBlob           = _cloudBlobClient.GetBlobReferenceFromServer(new Uri(_cloudBlobClient.BaseUri, blobKey));

            if (cloudBlob.Exists())
            {
                var stream = new MemoryStream();
                cloudBlob.DownloadToStream(stream);
                if (stream.CanSeek)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                }
                retVal = stream;
            }
            return(retVal);
        }
コード例 #25
0
 public virtual void DeletePackageFromBlob(
     StorageManagementClient storageClient,
     string storageName,
     Uri packageUri)
 {
     StorageAccountGetKeysResponse keys = storageClient.StorageAccounts.GetKeys(storageName);
     string storageKey = keys.PrimaryKey;
     var storageService = storageClient.StorageAccounts.Get(storageName);
     var blobStorageEndpoint = storageService.StorageAccount.Properties.Endpoints[0];
     var credentials = new StorageCredentials(storageName, storageKey);
     var client = new CloudBlobClient(blobStorageEndpoint, credentials);
     ICloudBlob blob = client.GetBlobReferenceFromServer(packageUri);
     blob.DeleteIfExists();
 }
コード例 #26
0
ファイル: ImageUploader.cs プロジェクト: llenroc/swetugg-web
        public void DeleteImage(string imageUrl)
        {
            try
            {
                CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();

                var blob = blobClient.GetBlobReferenceFromServer(new Uri(imageUrl));
                blob.Delete();
            }
            catch (Exception e)
            {
                throw new ImageUploadException("Image deletion failed", e);
            }
        }
コード例 #27
0
        public string[] ToStringsForEveryLine(AiBlobInfo aiBlobInfo)
        {
            var blobRef = _blobClient.GetBlobReferenceFromServer(aiBlobInfo.Uri);

            string text;

            using (var memStream = new MemoryStream())
            {
                blobRef.DownloadToStream(memStream);
                text = Encoding.Default.GetString(memStream.ToArray());
            }
            var stringlines = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            return(stringlines);
        }
        private CloudBlockBlob GetBlockBlob(Uri uri)
        {
            CloudBlockBlob blockBlob;

            if (!cachedBlobs.TryGetValue(uri.ToString(), out blockBlob))
            {
                blockBlob = cloudBlobClient.GetBlobReferenceFromServer(uri) as CloudBlockBlob;
                cachedBlobs.Add(uri.ToString(), blockBlob);
            }
            if (blockBlob == null)
            {
                logger.Warn <AzureBlobFileSystem>("File not found in BLOB: " + uri.AbsoluteUri);
            }
            return(blockBlob);
        }
コード例 #29
0
ファイル: Disks.cs プロジェクト: Viachaslau/azure-sdk-tools
        public static void RemoveVHD(IServiceManagement channel, string subscriptionId, Uri mediaLink)
        {
            var accountName = mediaLink.Host.Split('.')[0];
            var blobEndpoint = new Uri(mediaLink.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));

            StorageService storageService;
            using (new OperationContextScope(channel.ToContextChannel()))
            {
                storageService = channel.GetStorageKeys(subscriptionId, accountName);
            }

            var storageAccountCredentials = new StorageCredentials(accountName, storageService.StorageServiceKeys.Primary);
            var client = new CloudBlobClient(blobEndpoint, storageAccountCredentials);
            var blob = client.GetBlobReferenceFromServer(mediaLink);
            blob.DeleteIfExists();
        }
コード例 #30
0
        /// <summary>
        /// Deletes all blobs in all containers.
        /// Used only in tests tear-down method
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        public static void DeleteAllBlobs(string connectionString)
        {
            CloudBlobClient _client = TableStorage.StorageAccount(connectionString).CreateCloudBlobClient();

            _client.DefaultRequestOptions = GetDefaultBlobRequestOptions();

            foreach (CloudBlobContainer containerRef in _client.ListContainers())
            {
                IEnumerable <IListBlobItem> blobs = containerRef.ListBlobs(useFlatBlobListing: true);
                foreach (IListBlobItem blob in blobs)
                {
                    var blobRef = _client.GetBlobReferenceFromServer(blob.Uri); // v.1.7: GetBlobReference(blob.Uri.AbsoluteUri)
                    blobRef.DeleteIfExists();
                }
            }
        }
コード例 #31
0
        public static string GetBlob(string account, string key, string blobUrl)
        {
            if (string.IsNullOrEmpty(blobUrl))
            {
                return(null);
            }

            CloudBlobClient blobClient = Client.GetBlobClient(account, key);
            ICloudBlob      blob       = blobClient.GetBlobReferenceFromServer(new Uri(blobUrl));

            string tmpPath = Path.GetTempFileName();

            blob.DownloadToFile(tmpPath, FileMode.Create);

            return(tmpPath);
        }
コード例 #32
0
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            CloudBlobClient blobClient  = new CloudBlobClient(new Uri(request.DataStore.GetValue("storageBaseUrl")));
            CloudBlob       blob        = (CloudBlob)blobClient.GetBlobReferenceFromServer(new Uri(request.DataStore.GetValue("blobUrl")));
            string          contentName = request.DataStore.GetValue("blobContentName");

            string content = string.Empty;

            using (StreamReader sr = new StreamReader(blob.OpenRead()))
            {
                content = sr.ReadLine();
            }

            request.DataStore.AddToDataStore(contentName, content, DataStoreType.Public);

            return(new ActionResponse(ActionStatus.Success));
        }
コード例 #33
0
        public static void DownloadTestCredentials(string testEnvironment, string downloadDirectoryPath, string blobUri, string storageAccount, string storageKey)
        {
            string             containerPath = string.Format(EnvironmentPathFormat, testEnvironment);
            StorageCredentials credentials   = new StorageCredentials(storageAccount, storageKey);
            CloudBlobClient    blobClient    = new CloudBlobClient(new Uri(blobUri), credentials);
            CloudBlobContainer container     = blobClient.GetContainerReference(containerPath);

            foreach (IListBlobItem blobItem in container.ListBlobs())
            {
                ICloudBlob blob = blobClient.GetBlobReferenceFromServer(blobItem.Uri);
                Console.WriteLine("Downloading file {0} from blob Uri {1}", blob.Name, blob.Uri);
                FileStream blobStream = new FileStream(Path.Combine(downloadDirectoryPath, blob.Name), FileMode.Create);
                blob.DownloadToStream(blobStream);
                blobStream.Flush();
                blobStream.Close();
            }
        }