Azure functions 缺少以CloudBlockBlob作为输入触发器的元数据
在Blob存储(Data Lake Gen2)上的eventgrid触发器上使用Azure function 3.0(dotnet)。出于某种原因,我没有在“inputBlob”(类型为CloudBlockBlob)中获取与blob关联的元数据。你知道为什么元数据没有被填充吗?(我可以在Azure门户中看到blob的元数据) 这是文件: 如果找到存储资源的属性或元数据值 尚未填充,然后检查代码是否调用 FetchAttributes或FetchAttributesAsync方法Azure functions 缺少以CloudBlockBlob作为输入触发器的元数据,azure-functions,azure-function-app,Azure Functions,Azure Function App,在Blob存储(Data Lake Gen2)上的eventgrid触发器上使用Azure function 3.0(dotnet)。出于某种原因,我没有在“inputBlob”(类型为CloudBlockBlob)中获取与blob关联的元数据。你知道为什么元数据没有被填充吗?(我可以在Azure门户中看到blob的元数据) 这是文件: 如果找到存储资源的属性或元数据值 尚未填充,然后检查代码是否调用 FetchAttributes或FetchAttributesAsync方法 您没有获取b
您没有获取blob对象的属性,因此没有任何内容。请看一下我的答案。@SowmyanSoman你能标记我的答案来结束这个问题吗?:)
[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);
}
}
}