Question

Difficulty: MediumImplement Durable Functions

You are developing a workflow to process monthly customer billing reports using Azure Durable Functions in a C# (.NET Isolated process) environment. You need to write an HTTP-triggered function that starts a new instance of the orchestrator function named BillingReportOrchestrator and returns a standard HTTP 202 response containing the status check URI. Which code segment should you use?

  1. [Function("StartBillingReport")]
    public static async Task<HttpResponseData> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
    [DurableClient] DurableTaskClient client)
    {
    string instanceId = await client.ScheduleNewOrchestratorInstanceAsync("BillingReportOrchestrator");
    return client.CreateCheckStatusResponse(req, instanceId);
    }
    Answer
  2. B
    [Function("StartBillingReport")]
    public static async Task<HttpResponseMessage> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage req,
    [DurableClient] IDurableOrchestrationClient client)
    {
    string instanceId = await client.StartNewAsync("BillingReportOrchestrator");
    return client.CreateCheckStatusResponse(req, instanceId);
    }
  3. C
    [Function("StartBillingReport")]
    public static async Task<HttpResponseData> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
    [DurableClient] DurableTaskClient client)
    {
    string instanceId = await client.StartNewAsync("BillingReportOrchestrator");
    return client.CreateCheckStatusResponse(req, instanceId);
    }
  4. D
    [Function("StartBillingReport")]
    public static async Task<HttpResponseData> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
    [OrchestrationClient] DurableTaskClient client)
    {
    string instanceId = await client.ScheduleNewOrchestratorInstanceAsync("BillingReportOrchestrator");
    return client.CreateCheckStatusResponse(req, instanceId);
    }

Answer

The correct code segment binds to a DurableTaskClient instance using the [DurableClient] attribute, schedules the execution using client.ScheduleNewOrchestratorInstanceAsync, and yields the status endpoints with client.CreateCheckStatusResponse using HttpResponseData.
In C# .NET Isolated process functions, the modern Durable Functions extension shifts to using DurableTaskClient to manage orchestrations. To schedule a workflow, the ScheduleNewOrchestratorInstanceAsync method is called. The HTTP payload handles input/output using HttpRequestData and HttpResponseData, and status URL payloads are generated via CreateCheckStatusResponse.

Step-by-Step Solution

1
Determine the execution process model context.
The requirements specify the C# (.NET Isolated process) model.
This helps filter out types that only exist in the In-Process model.
2
Identify the correct bindings and classes for the client in the .NET Isolated model.
The [DurableClient] attribute binds to the DurableTaskClient class, whereas HttpRequestData and HttpResponseData represent the HTTP context.
The In-Process SDK class IDurableOrchestrationClient and standard HttpRequestMessage/HttpResponseMessage are not natively supported in the .NET Isolated model's durable extension.
3
Identify the method signature to trigger the orchestrator.
The method to invoke is client.ScheduleNewOrchestratorInstanceAsync("BillingReportOrchestrator").
The older StartNewAsync method belongs to the legacy in-process library and is absent from the newer DurableTaskClient interface.

Key Concept

Azure Durable Functions .NET Isolated Worker Client Bindings
Estimated Time:1m 30s
Rate this question