简体   繁体   English

Azure Function v1 中的 Azure 服务总线会话支持

[英]Azure Service Bus Session support in Azure Function v1

Disclaimer - I am new to the world of development on Azure.免责声明 - 我是 Azure 开发领域的新手。

I want to enable session based message handling in an Azure function which is based on ServiceBusTrigger.我想在基于 ServiceBusTrigger 的 Azure 函数中启用基于会话的消息处理。 I am able to do that by setting the attribute IsSessionsEnabled = true and having required session handler options in host.json.我可以通过设置属性IsSessionsEnabled = true并在 host.json 中设置所需的会话处理程序选项来做到这一点。

Sample snippet:示例片段:

//Azure function
public static void Run([ServiceBusTrigger("core-test-queue1-sessions", Connection = "AzureWebJobsServiceBus", IsSessionsEnabled = true)]string myQueueItem, ClientEntity clientEntity, ILogger log)

Session handler options in host.json host.json 中的会话处理程序选项

{
    "version": "2.0",
    "extensions": {
        "serviceBus": {
            "SessionHandlerOptions":
             {
                "MaxAutoRenewDuration": "00:01:00",
                "MessageWaitTimeout": "00:05:00",
                "MaxConcurrentSessions": 16,
                "AutoComplete": true,
             }
        }
    }
}

This is working fine in Azure Function v2.这在 Azure Function v2 中运行良好。 How to implement this in Azure Function v1 as the attribute IsSessionsEnabled and SessionHandlerOptions are not available in v1?由于属性 IsSessionsEnabled 和 SessionHandlerOptions 在 v1 中不可用,如何在 Azure Function v1 中实现此功能? Please suggest a workaround for this.请为此提出一个解决方法。

Use the Service Bus trigger to respond to messages from a Service Bus queue or topic.使用服务总线触发器响应来自服务总线队列或主题的消息。 Starting with extension version 3.1.0, you can trigger on a session-enabled queue or topic.从扩展版本 3.1.0 开始,您可以在启用会话的队列或主题上触发。

But function v1 package is consists of service bus extension 2.xx, so you can not enable session in Azure function v1.但是功能 v1 包由服务总线扩展 2.xx 组成,因此您无法在 Azure 功能 v1 中启用会话。

You can refer to this document:你可以参考这个文档:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=csharp https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=csharp

You can see the version of the package here:您可以在此处查看软件包的版本:

在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM