Last active
September 6, 2018 21:20
-
-
Save kevinhillinger/9119f62af3fa0873d1c1b12bca8e5d48 to your computer and use it in GitHub Desktop.
Azure Functions - Azure Blob Storage - Streaming block blobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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