【发布时间】:2020-11-05 11:31:47
【问题描述】:
我正在使用 Azure Functions 和 Azure 服务总线实现 claim check pattern。
我的 Azure Function 有一个 ServiceBusTrigger,它自己可以正常工作。
public async Task Run(
[ServiceBusTrigger("worker", Connection = "SERVICE_BUS_CONNECTION")] string json,
ILogger log)
{
var notificationCommand = JsonConvert.DeserializeObject<NotificationCommand>(json, new JsonNotificationCommandConverter());
来自总线的序列化声明检查消息如下所示:
{
"type": "claim-check",
"product": "XYZ",
"payloadRef": "https://{storage-account}/{container}/{blob_id}"
}
我希望能够只使用 Blob 输入绑定从 BLOB 存储中获取有效负载引用,而无需手动执行,但我在绑定表达式方面遇到了一些问题 - 我什至没有确定是否有可能做我正在尝试的事情......
基本上我想做以下事情:
public async Task Run(
[ServiceBusTrigger("worker", Connection = "SERVICE_BUS_CONNECTION")] string json,
[Blob("{PayloadReference}", FileAccess.Read, Connection = "BLOB_STORAGE_CONNECTION")] Stream myBlob,
ILogger log)
{
var notificationCommand = JsonConvert.DeserializeObject<NotificationCommand>(json, new JsonNotificationCommandConverter());
其中Blob("{PayloadReference}" 指的是来自总线的 json 消息中的一个属性。
有可能吗?如果是这样,我该怎么做...
【问题讨论】:
-
blob 属性示例仅显示“{container}/{blob_id}”。它们没有显示提供完整 uri 的示例。
-
不确定是否是拼写错误甚至相关,但我注意到绑定有“PayloadReference”,但有效负载字段较短“payloadRef”且大小写不同。
标签: azure-functions azureservicebus