从触发Blob触发Azure函数的文件中获取元数据

时间:2018-07-25 17:32:09

标签: azure data-binding azure-storage-blobs azure-functions azure-triggers

我有一个Blob触发器Azure函数,每次将新文件添加到我的Blob存储中时都会调用该函数。我自动获得该文件的名称作为输入。除了名称,我还需要附加到给定文件的元数据。我一直在研究数据输入绑定,但我无法理解。我需要做什么来获取文件元数据作为输入?或者,甚至只是在我的函数中访问它?

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

1 个答案:

答案 0 :(得分:3)

您可以绑定到Stream,而不是绑定到CloudBlockBlob。然后,您可以做

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

如果需要流,则可以调用.OpenRead().OpenReadAsync()

相关问题