我定义了一个Azure函数,该函数使用Azure存储队列触发器和Blob输入绑定。我有一个用于队列触发器的POCO,但是如何在Blob输入绑定中将该POCO与绑定表达式一起使用?
建筑:
POCO:
public class ImageToProcess
{
public int CompanyId { get; set; }
public string FullImagePath { get; set; }
}
天蓝色功能
public static void Run(
[QueueTrigger("profile-image-queue", Connection = "ProfileImageQueue")]ImageToProcess myQueueItem,
[Blob("profileimages/{queueTrigger.FullImagePath}", FileAccess.Read, Connection = "ProfileImageBlobConnectionString")] Stream originalImage,
ILogger log)
{
log.LogInformation($"Started Processing profile image: myQueueItem");
}
队列消息:
{
"CompanyId": 123,
"FullImagePath": "CompanyA/profileImage-original.png"
}
错误消息:
System.Private.CoreLib:执行函数ProfileProfileUploaded时发生异常。 Microsoft.Azure.WebJobs.Host:异常绑定参数“ originalImage”。 Microsoft.Azure.WebJobs.Host:访问“ FullImagePath”时出错:属性不存在。
用于创建此解决方案的资源
其他潜在解决方案: 我看到的唯一其他选择是使用命令式绑定,但是我很确定可以使用声明式绑定。 https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#binding-at-runtime
答案 0 :(得分:1)
在Blob绑定中使用以下内容:
"profileimages/{FullImagePath}"
请注意,如果 FullImagePath 表示网址,则:
"{FullImagePath}"