Skip to content

Instantly share code, notes, and snippets.

@kevinhillinger
Last active September 6, 2018 21:20
Show Gist options
  • Save kevinhillinger/9119f62af3fa0873d1c1b12bca8e5d48 to your computer and use it in GitHub Desktop.
Save kevinhillinger/9119f62af3fa0873d1c1b12bca8e5d48 to your computer and use it in GitHub Desktop.
Azure Functions - Azure Blob Storage - Streaming block blobs
// generic use of SDK
var account = new CloudStorageAccount(credentials, true);
var client = new CloudBlobClient(account.BlobEndpoint.AbsoluteUri, account.Credentials);
var container = client.GetContainerReference("test");
var blob = container.GetBlobReference("CloudBlob.txt");
using (var stream = blob.OpenRead())
{
using (var reader = new StreamReader(stream))
{
while (!reader.EndOfStream)
{
Console.WriteLine(reader.ReadLine());
}
}
}
// azure function using stream bindings-storage-blob
// https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob
public static void Run(Stream stream, TraceWriter log)
{
using (var reader = new StreamReader(stream))
{
while (!reader.EndOfStream)
{
var row = reader.ReadLine();
//TODO: open stream to JSON blob and write JSON
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment