You are designing a serverless workflow using Azure Durable Functions in C# (.NET Isolated) to manage a vehicle fleet maintenance process. The orchestrator function must query an external vehicle diagnostics REST API to retrieve real-time fault codes before deciding which maintenance tasks to execute.
Which of the following is the correct way to implement this external API call while complying with the determinism requirements of Durable Functions?
- Delegate the REST API call to an Activity function called by the orchestrator, or use the orchestration context's built-in HTTP APIs.Answer
- BUse the HttpClient class inside a Task.Run block to execute the API call asynchronously within the orchestrator.
- CDefine a static HttpClient instance and perform an asynchronous GetAsync call directly in the orchestrator method.
- DUpgrade the hosting plan of the Function App to a Premium App Service plan to permit outbound HTTP calls from the orchestrator.
Answer
Delegate the REST API call to an Activity function called by the orchestrator, or use the orchestration context's built-in HTTP APIs.
The correct answer is to delegate the REST API call to an Activity function or use the orchestration context's built-in HTTP APIs. Since orchestrator functions in Durable Functions must be completely deterministic, performing direct I/O (such as invoking external APIs via HttpClient) is not allowed. Activity functions do not have this restriction and are only executed once, with their results recorded in the execution history. Alternatively, the built-in CallHttpAsync method on the orchestration context can be used as it is designed to run deterministically during replays.
Step-by-Step Solution
Key Concept
Orchestrator determinism and out-of-process communication using Activity functions or built-in HTTP APIs