Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Function coded with spring-cloud-function-adapter-azure SDK cannot return value of form of Mono/Flux. #159

Open
alain-marcel opened this issue Nov 12, 2021 · 4 comments

Comments

@alain-marcel
Copy link

alain-marcel commented Nov 12, 2021

We are using the spring-cloud-function-adapter-azure SDK to build our function.
We expect the return value to be in the form of Mono and Flux, but the we cannot return the corresponding value.

The code link provided by the official website: Getting started with Spring Cloud Function in Azure | Microsoft Docs
After checking the code provided by the official website, we found that only the return value in the HTTP response format was provided as follows:

public class HelloHandler extends FunctionInvoker<User, Greeting> {
   
    @FunctionName("hello")
    public HttpResponseMessage execute(
        @HttpTrigger(name = "request", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<User>> request,
        ExecutionContext context) {
        User user = request.getBody()
                           .filter((u -> u.getName() != null))
                           .orElseGet(() -> new User(
                               request.getQueryParameters()
                                      .getOrDefault("name", "world")));
        context.getLogger().info("Greeting user name: " + user.getName());
        return request
            .createResponseBuilder(HttpStatus.OK)
            .body(handleRequest(user, context))
            .header("Content-Type", "application/json")
            .build();
    }}

I did not find the return form of Mono and Flux. The return format that we wanted is as follows:

public class HelloHandler extends FunctionInvoker<User, Mono<Greeting>> {

    @FunctionName("hello")
    public HttpResponseMessage execute(
        @HttpTrigger(name = "request", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<User>> request,
        ExecutionContext context) {
          // ...
}

We want to know whether the return of Mono and Flux is supported on Azure, because the customer found that .NET can return the corresponding value, as follows:

[FunctionName("Httpxample")]
public static async Task<IActionResult> Run(
   [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HtppREquest req,
   Iloogger log
   )

Please confirm the feasibility of this request. Thank you very much for your help.

@kaibocai
Copy link
Member

kaibocai commented Jan 5, 2023

Hi @alain-marcel , thanks for reaching out and sorry for the late reply. Did you still have this issue?

@alain-marcel
Copy link
Author

alain-marcel commented Jan 6, 2023 via email

@kaibocai
Copy link
Member

Hi @alain-marcel , I am investigating the possible solution for non-blocking/reactive invocation, I am trying to understand how .NET is supporting this. It will be great if you can share any docs on .NET about this feature.

Attach the sample issue from the java worker repo: Azure/azure-functions-java-worker#244

@alain-marcel
Copy link
Author

alain-marcel commented Jan 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants