gpt4 book ai didi

Azure函数: How do you use a POCO in a binding expression with Azure Storage Queue?

转载 作者:行者123 更新时间:2023-12-02 06:42:45 26 4
gpt4 key购买 nike

我定义了一个使用 Azure 存储队列触发器和 Blob 输入绑定(bind)的 Azure 函数。我有一个用于队列触发器的 POCO,但是如何将该 POCO 与 Blob 输入绑定(bind)中的绑定(bind)表达式一起使用?

建筑:

  1. Azure 函数 2.x
  2. 预编译的 C# 库 (.NET Core 2.1)

POCO:

public class ImageToProcess
{
public int CompanyId { get; set; }
public string FullImagePath { get; set; }
}

Azure 函数:

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: Exception while executing function: ProfileImageUploaded. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'originalImage'. Microsoft.Azure.WebJobs.Host: Error while accessing 'FullImagePath': property doesn't exist.

用于创建此解决方案的资源

  1. http://dontcodetired.com/blog/post/Improving-Azure-Functions-Blob-Trigger-Performance-and-Reliability-Part-2-Processing-Delays-and-Missed-Blobs
  2. https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue#trigger
  3. https://learn.microsoft.com/en-us/sandbox/functions-recipes/queue-storage#azure-storage-queue-trigger-using-a-poco

其他潜在的解决方案:我看到的唯一其他选择是使用命令式绑定(bind),但我很确定我可以使用声明式绑定(bind)。 https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#binding-at-runtime

最佳答案

在 Blob 绑定(bind)中使用以下内容:

"profileimages/{FullImagePath}" 

注意,如果FullImagePath代表一个url地址,那么:

"{FullImagePath}" 

关于Azure函数: How do you use a POCO in a binding expression with Azure Storage Queue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58237339/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com