azure - 通过 HTTP 端点触发时,带有 enqueueTimeUtc 参数的 ServiceBusTrigger 失败

标签 azure azure-functions

我正在使用 Visual Studio 2017 在本地 Azure Functions v1 中开发服务总线触发器。我想测试 example来自官方文档,无需在服务总线中添加消息。所以我通过 Postman 在端点 POST http://localhost:7071/admin/functions/ServiceBusQueueTriggerCSharp 触发它与正文 { "input": "foo"}.

此操作失败,并出现脚本主机错误:执行函数时出现异常:ServiceBusQueueTriggerCSharp。 Microsoft.Azure.WebJobs.Host:发生一个或多个错误。异常绑定(bind)参数“deliveryCount”。 Microsoft.Azure.WebJobs.Host:绑定(bind)数据不包含预期值“deliveryCount”。

我尝试删除 deliveryCount 参数,但在 enqueueTimeUtc 处失败。删除它也有效。有没有办法保留这些参数并在本地测试函数?

我知道这两个参数在通过 HTTP 触发时没有多大意义,但可以为它们指定默认值。 messageId 具有非零值。

引用示例:

[FunctionName("ServiceBusQueueTriggerCSharp")]                    
public static void Run(
    [ServiceBusTrigger("myqueue", AccessRights.Manage, Connection = "ServiceBusConnection")] 
    string myQueueItem,
    Int32 deliveryCount,       // this fails
    DateTime enqueuedTimeUtc,  // this fails too
    string messageId,
    TraceWriter log)
{
    log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
    log.Info($"EnqueuedTimeUtc={enqueuedTimeUtc}");
    log.Info($"DeliveryCount={deliveryCount}");
    log.Info($"MessageId={messageId}");
}

最佳答案

截至目前,如果您希望能够使用这些附加元数据属性,则需要使用真正的服务总线消息。

理论上,管理端点可能足够智能,允许您传递额外的绑定(bind)数据(例如本例中的deliveryCount)作为查询参数。我提交了以下功能请求来跟踪: https://github.com/Azure/azure-functions-host/issues/2955

关于azure - 通过 HTTP 端点触发时,带有 enqueueTimeUtc 参数的 ServiceBusTrigger 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50725773/

相关文章:

powershell - 如何导出 Azure 订阅上的 "administrators"列表?

asp.net - Azure ACS 身份验证如何确保安全?

python-3.x - 如何使用python将blob从Azure存储复制到linux虚拟机?

azure - 在 Azure 中通过 powershell 删除号码并撤销 MFA session 的命令

Azure 应用程序配置推送任务 - 如何使用此任务在 azure 应用程序配置中部署 key 保管库引用值?

c# - 我可以、如何向 Azure Function 提供设置文件?

c# - 计算来自两个Azure函数应用程序的两个服务总线主题之间的时间跨度指标

c# - 来自 Azure 函数中使用的类库的日志消息

python - Azure Functions for python、结构化日志记录到 Application Insights?

Azure AD Graph API 邀请端点