【问题标题】:Is it possible for Azure function listening multiple blob for blob triggerAzure函数是否可以侦听多个blob以触发blob
【发布时间】:2020-09-27 18:05:53
【问题描述】:

我需要创建单个 azure 函数来监听多个 blob 容器。可能吗?

【问题讨论】:

    标签: azure azure-active-directory azure-functions


    【解决方案1】:

    不,每个 Azure 函数都有正好一个触发器。但是,个替代方案。您可以在泛型方法中实现对 blob 的处理,定义多个函数并让它们都调用泛型方法。

    类似(伪代码):

    [FunctionName("BlobTriggerContainer1")]
    public static async Task Run([BlobTrigger("container1/{name}")]Stream fileBlob, string name)
    {
        await DoTheMagicAsync(fileBlob, name);
    }
    
    [FunctionName("BlobTriggerContainer2")]
    public static async Task Run([BlobTrigger("container2/{name}")]Stream fileBlob, string name)
    {
        await DoTheMagicAsync(fileBlob, name);
    }
    
    private void DoTheMagicAsync(Stream stream, string name)
    {
        // Do your (async) magic here
    }
    

    另一种解决方案是使用 Azure 事件网格。有关如何组合这些服务的更多信息,请参阅Tutorial: Automate resizing uploaded images using Event Grid

    【讨论】:

      猜你喜欢
      • 2019-05-18
      • 2019-02-15
      • 2021-10-08
      • 1970-01-01
      • 2020-06-09
      • 2022-01-08
      • 2018-10-03
      • 1970-01-01
      • 2021-05-27
      相关资源
      最近更新 更多