使用 CloudBlockBlob 作为输入触发器时缺少元数据

Missing metadata with CloudBlockBlob as input trigger

在 Blob 存储 (Data Lake Gen2) 上的事件网格触发器上使用 Azure 函数 3.0 (dotnet)。出于某种原因,我没有在“inputBlob”(CloudBlockBlob 类型)中获取与 blob 关联的元数据。知道为什么没有填充元数据吗? (我可以在 Azure 门户中看到 blob 的元数据)

 [FunctionName("Processor")]
        public static async Task RunAsync([EventGridTrigger]EventGridEvent eventGridEvent,
            [Blob("{data.url}", FileAccess.Read, Connection = "StorageConnectionString")] CloudBlockBlob inputBlob,
            ILogger log)
        {
           if (inputBlob != null)
            {
                int metaCount = inputBlob.Metadata.Count; // its zero
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.Azure.Storage.Blob;
using Azure.Storage.Blobs;

namespace FunctionApp39
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            [Blob("test1/1119.png", FileAccess.Read, Connection = "str")] CloudBlockBlob myBlob,
            ILogger log)
        {
            myBlob.FetchAttributes(); //Need to fetch.
            var s = myBlob.Metadata;
            foreach (var metadataItem in s)
            {
                log.LogInformation($"\tKey: {metadataItem.Key}");
                log.LogInformation($"\tValue: {metadataItem.Value}");
            }
            int a = myBlob.Metadata.Count;
            log.LogInformation("!!!!!!!!!!!!!!!!" + a);
        }
    }
}

这是文档:

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-container-properties-metadata?tabs=dotnet11#retrieve-container-properties

If you find that property or metadata values for a storage resource have not been populated, then check that your code calls the FetchAttributes or FetchAttributesAsync method.