基于Java的Azure函数的服务总线输出绑定不工作没有错误
我尝试构建基于Java的Azure函数,由HTTP触发,并将数据发送到服务总线的主题。这是基于示例代码。HTTP触发器工作正常(返回Hello name),但我没有收到任何发送到服务总线的数据。我没有收到错误信息。我已经用基于C#的函数进行了测试,该函数在本地。设置。json是正确的
/* 20.3.2020 HTTP Trigger and Topic output binding*/
package com.function;
import java.util.*;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;
/**
* Azure Functions with HTTP Trigger.
*/
public class HttpTriggerSBOutputJava {
/**
* This function listens at endpoint "/api/HttpTriggerSBOutputJava". Two ways to invoke it using
"curl" command in bash:
* 1. curl -d "HTTP Body" {your host}/api/HttpTriggerSBOutputJava
* 2. curl {your host}/api/HttpTriggerSBOutputJava?name=HTTP%20Query
*/
@FunctionName("HttpTriggerSBOutputJava")
public HttpResponseMessage run(
@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
@ServiceBusTopicOutput(name = "message", topicName = "ContactInformationChanged", subscriptionName = "Playground", connection = "queueconstring") OutputBinding<String> message,
final ExecutionContext context) {
String name = request.getBody().orElse("Azure Functions");
message.setValue(name);
return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
}
}
共 (0) 个答案