Skip to content

Instantly share code, notes, and snippets.

@DavidRogersDev
Created December 30, 2014 00:36
Show Gist options
  • Save DavidRogersDev/d877bcf6617eeb90285a to your computer and use it in GitHub Desktop.
Save DavidRogersDev/d877bcf6617eeb90285a to your computer and use it in GitHub Desktop.
Quick and dirty program that reads the text of some blobs which were written as log output from a webjob.
class Program
{
private static string Name = "myContainer";
private static string Key =
"R5+BFCGHDJSghjkngfdjklggjfdkj+gvhdfkgfdjkgfdhjgHJGKFDGF==";
static void Main(string[] args)
{
var storageCredentials = new StorageCredentials(Name, Key);
var cloudStorageAccount = new CloudStorageAccount(storageCredentials, false);
var blobStorage = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobStorage.GetContainerReference("azure-webjobs-hosts");
List<IListBlobItem> blobs = null;
if (container.CreateIfNotExists())
{
blobs = container.ListBlobs().Take(10).ToList();
}
//blobs = container.ListBlobs().Take(10).ToList();
blobs = container.ListBlobs().Take(10).Where(b => b.StorageUri.ToString().Contains(@"output-logs")).ToList();
foreach (var listBlobItem in blobs)
{
var oi = ((CloudBlobDirectory)listBlobItem).ListBlobs().OfType<CloudBlockBlob>().OrderByDescending(b => b.Properties.LastModified).Take(10);
foreach (var blobItem in oi)
{
Console.WriteLine(blobItem.DownloadText().ToString());
}
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment