【问题标题】:How to set isSessionsEnabled = true in function.json?如何在function.json中设置isSessionsEnabled = true?
【发布时间】:2021-12-17 04:36:07
【问题描述】:

当我构建 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
) {
  }
}
  • fucntion.json
{
  "scriptFile" : "../func.jar",
  "entryPoint" : "test.Function.run",
  "bindings" : [ {
    "type" : "serviceBusTrigger",
    "direction" : "in",
    "name" : "message",
    "queueName" : "queueName",
    "connection" : "ConnectionString"
  } ]
}

【问题讨论】:

  • 很遗憾,通过设置来定义 IsSessionEnabled 是不可行的。队列名称可以通过在定义 ServiceBusQueueAttribute 时使用 % 符号在设置文件中定义,如 here 所示,虽然该示例适用于 C#,但它也适用于 Java。

标签: java azure azure-functions


【解决方案1】:

如何在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 文件的配置属性的list

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2018-09-14
    • 2019-05-12
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多