简体   繁体   English

如何在隔离的 Azure 函数 v4 中获取消息元数据 - c# 中的队列触发器

[英]How to get message metadata in isolated Azure functions v4 - Queue Trigger in c#

I am following on a possible upgrade of azure function runtime from v3 to v4 with do.net.我正在关注使用 do.net 将 azure function 运行时从 v3 升级到 v4 的可能性。 While doing so, I am testing out the isolated option for the project.在这样做的同时,我正在测试项目的隔离选项。 However I am unable to get message metadata such as DequeueCount, MessageId etc in the queue trigger.但是,我无法在队列触发器中获取消息元数据,例如 DequeueCount、MessageId 等。

Previously with in-process option, I used to bind CloudQueueMessage but that doesn't seem to work in the isolated mode.以前使用进程内选项,我曾经绑定CloudQueueMessage但这似乎在隔离模式下不起作用。 Doing so, throws and error -这样做,抛出和错误 -

Cannot convert input parameter 'myQueueItem' to type 'Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage' from type 'System.String'

This was my isolated queue function binding这是我的隔离队列 function 绑定

[Function("TestApp")]
public void Run([QueueTrigger("sample-queue", Connection = "")] CloudQueueMessage myQueueItem, FunctionContext context)

After looking for a while, I think here it says that, in isolated process we can only bind string.看了一会儿,我想这里说的是,在孤立的过程中,我们只能绑定字符串。 Simple JSON - Object also works.简单的 JSON - Object 也可以。

在此处输入图像描述

Is there any way to get these message metadata (members of the CloudQueueMessage ) in the isolated azure function?有没有办法在隔离的 azure function 中获取这些消息元数据CloudQueueMessage的成员)? Thanks.谢谢。

For DequeueCount property I use this:对于 DequeueCount 属性,我使用这个:

[Function("MyQueueTrigger")]
public void Run([QueueTrigger("my-queue-name")] string myQueueItem, int dequeueCount)
{
    _logger.LogInformation("Queue item: {item}. Dequeue count: {dequeueCount}.", myQueueItem, dequeueCount);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Functions V4 // ServiceBusTrigger 和绑定属性,如 Message 或 MessageReceiver - Azure Functions V4 // ServiceBusTrigger and binding properties like Message or MessageReceiver 使用 C# 通过 SessionId 获取 Azure 服务总线队列活动消息计数 - get Azure Service Bus Queue active message count by SessionId using C# 如何从事件网格触发器中获取 blob 的元数据 Azure Function - How to get metadata of a blob from Event Grid Trigger in Azure Function Azure Function App v4 Blob 触发并发 - Azure Function App v4 Blob Trigger Concurrency 具有 Azure 函数的定时器触发器 V3 (.NET 5) - Timer Trigger with Azure Functions V3 (.NET 5) Azure Functions v4 序列化为驼峰式 Cosmos DB - Azure Functions v4 serialize to Cosmos DB in camel case 如何在 c# 中以编程方式检查队列触发器 function 的状态? - How to check status of queue trigger function programmatically in c#? Azure 函数:是否可以为队列触发器提供多个参数? - Azure functions: is it possible to give multiple parameters to a queue trigger? Botframework v4 对于所有用户相同 state C# - Botframework v4 same state for all users C# 调用 Azure Function(队列触发器)不起作用,但是当我从 azure 门户发送消息时它起作用 - Calling Azure Function ( Queue Trigger) Doesnt work , but it does when i send i message from azure portal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM