3
votes

I have an blob trigger Azure function that is called every time a new file is added to my blob storage. I get the name of that file as an input automatically. In addition to the name, I need the metadata attached to the given file. I've been looking into data input bindings, but I can't make sense of it. What do I need to do to get the file metadata as an input? Or, even just access it within my function?

public static void Run(Stream myBlob, string name, TraceWriter log)
{
    string result = DoSomethingWithFileName(name);
    var something = DoSomethingWithFileMetadata();
}
1

1 Answers

6
votes

instead of binding to a Stream you can bind to a CloudBlockBlob. You can then do

public static Task Run(CloudBlockBlob myBlob, string name, TraceWriter log)
{
    string result = DoSomethingWithFileName(myBlob.Name);
    var something = DoSomethingWithFileMetadata(myBlob.Metadata);
}

And if you need the stream, you can then call .OpenRead() or .OpenReadAsync()