微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从 blobtrigger azure 函数 c# 中获取多个文件名

如何解决如何从 blobtrigger azure 函数 c# 中获取多个文件名

如何使用 blobtrigger azure 函数 c# 从容器中获取多个文件名?

解决方法

更新:

Sample:

using System;
using System.IO;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Blob;

namespace FunctionApp116
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([BlobTrigger("test/{name}",Connection = "str")]CloudBlockBlob myBlob,ILogger log)
        {
            string blobname = myBlob.Name;
            string containername = myBlob.Container.Name;
            BlobServiceClient blobServiceClient = new BlobServiceClient(Environment.GetEnvironmentVariable("str"));
            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containername);
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{blobname}" + $" Container Name is {containername}");
            foreach (BlobItem blobItem in containerClient.GetBlobs())
            {
                log.LogInformation("\t" + blobItem.Name);
            }

        }
    }
}

enter image description here

原答案:

blob 触发器可以输入的 blob 不能超过一个。

但是,您可以使用 blob 存储 sdk 从同一个容器中获取多个 blob。

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet#code-examples

如果您提供您使用的语言,我可以发布示例。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。