首页 > 解决方案 > 如何在function.json中设置isSessionsEnabled = true?

问题描述

当我构建 Azure Function (Java) 的以下代码时,生成的 function.json 中未设置 isSessionsEnabled。

如何在function.json中设置isSessionsEnabled = true?

该构建使用 Gradle。

https://github.com/microsoft/azure-gradle-plugins/blob/master/azure-functions-gradle-plugin/README.md


public class Function {

@FunctionName("FunctionApp")
public void run(
        @ServiceBusQueueTrigger(
               name = "TriggerName",
               queueName = "queueName",
               connection = "ConnectionString", 
               isSessionsEnabled = true
        ) String message,
        ExecutionContext context
) {
  }
}
{
  "scriptFile" : "../func.jar",
  "entryPoint" : "test.Function.run",
  "bindings" : [ {
    "type" : "serviceBusTrigger",
    "direction" : "in",
    "name" : "message",
    "queueName" : "queueName",
    "connection" : "ConnectionString"
  } ]
}

标签: javaazureazure-functions

解决方案


如何在function.json中设置isSessionsEnabled = true?

从服务总线触发器扩展版本 3.1.0 开始,您可以在启用会话的队列或主题上触发。

您可以在function.json 中添加isSessionsEnabled =true

{
  "scriptFile" : "../func.jar",
  "entryPoint" : "test.Function.run",
  "bindings" : [ {
    "type" : "serviceBusTrigger",
    "direction" : "in",
    "name" : "message",
    "queueName" : "queueName",
    "connection" : "ConnectionString",
    "isSessionsEnabled" : true
  } ]
}

以下是您可以添加到function.json文件的配置属性列表。


推荐阅读