【问题标题】:Get metadata from file that triggered blob trigger Azure function从触发 blob 触发 Azure 函数的文件中获取元数据
【发布时间】:2019-01-02 14:44:05
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

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

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

    如果您需要流,则可以致电.OpenRead().OpenReadAsync()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-17
      • 2021-10-08
      • 1970-01-01
      • 2020-05-13
      • 2020-06-09
      • 1970-01-01
      • 2021-12-26
      • 2022-01-08
      相关资源
      最近更新 更多