Achindra Bhatnagar
Published © MIT

Azure Function Apps; Running Custom Code on Blob Insertion

Writing SQL style triggers or stitching action to events in Azure has become easier.

IntermediateProtip4 hours3,844
Azure Function Apps; Running Custom Code on Blob Insertion

Things used in this project


Read more


Code snippet

using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;

public static void Run(Stream inputBlob, Stream thumbnailBlob, TraceWriter log)
    string SubscriptionKey = "CognitiveServiceKey";

    using (var httpClient = new HttpClient())
        httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", SubscriptionKey);
        using (HttpContent content = new StreamContent(inputBlob))
            content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/octet-stream");
            var uri = "";
            var response = httpClient.PostAsync(uri, content).Result;
            var responseBytes = response.Content.ReadAsByteArrayAsync().Result;

            //write to output thumb
            thumbnailBlob.Write(responseBytes, 0, responseBytes.Length);


Achindra Bhatnagar

Achindra Bhatnagar

20 projects • 141 followers
Windows Kernel Hacker, IoT Hobbyist, Enthusiast, Developer and Dreamer