Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
429 stars 183 forks source link

CreateCheckStatusResponse does not work when `HttpRequestMessage` is used (no built-in Function HTTP types) #2361

Open Fazer01 opened 7 months ago

Fazer01 commented 7 months ago

Description

When using .ConfigureFunctionsWebApplication() instead of .ConfigureFunctionsWorkerDefaults() (following https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#aspnet-core-integration) and we have an http trigger endpoint to start an orchestration like the following:

[Function(nameof(HttpStart))]
public static async Task<HttpResponse> HttpStart(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req,
    [DurableClient] DurableTaskClient client,
    FunctionContext executionContext)
{
    ILogger logger = executionContext.GetLogger(nameof(HttpStart));

    // Function input comes from the request content.
    string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
        nameof(RunOrchestrator));

    logger.LogDebug("Started orchestration with ID = '{instanceId}'.", instanceId);

    // Returns an HTTP 202 response with an instance management payload.
    // See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration
    return client.CreateCheckStatusResponse(req, instanceId);
}

The line return client.CreateCheckStatusResponse(req, instanceId); gives a compile error, because req is not an HttpRequestData type. We would really love to use the ASP.NET Core integration to use normal .NET 8 types instead of using the built-in Function HTTP (HttpRequestData and HttpResponseData) types.

Looking forward to hear from you guys, Regards,

Tom

If this is not the right repository to mention the issue, my apologies

Steps to reproduce

Use the Durable Functions template in Visual Studio 2022 Preview to create the durable functions (isolated) and change the line in the startup to use the ASP.NET core .NET8 http types instead of the built-in function http types. Then in the HTTP-trigger to start the orchestration change the HttpRequestData type in HttpRequestMessage will fail the CreateCheckStatusResponse(...) function to compile.

ahaleiii commented 2 months ago

Similar conversation in the durable function repo:

https://github.com/Azure/azure-functions-durable-extension/issues/2717#issuecomment-1887987410

smolattack commented 1 month ago

Similar conversation in the durable function repo:

Azure/azure-functions-durable-extension#2717 (comment)

Having read that thread, I'm none the wiser. I can't find a single example of how to call a durable function with a JSON body that both compiles and contains a non-empty request Body.