> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AD-001 Use Azure Durable Functions for report orchestration

> AD-001 Use Azure Durable Functions for report orchestration for ReportGeneratorTool.

**Status:** Accepted **Decision date:** 2025-08-01 **Implementation:** Confirmed in the repository at commit `27045ec`.

## Context and decision drivers

Report generation and email delivery are sequential steps that may take time and fail independently. The service was intended for low request volume and small scale. The team wanted a simple setup with persisted workflow state and a way for callers to check progress.

## Options considered

| Option | Assessment at decision time |
| - | - |
| Azure Durable Functions | Provides orchestration, separate activities, persisted workflow state, and status endpoints within the Azure Functions application. |
| Kafka | Would introduce a separate messaging platform and require additional workflow sequencing and status handling. |
| Azure Service Bus | Would provide messaging, but the multi-step orchestration and status handling would still need to be built. |

## Decision and rationale

Use an Azure Durable Functions orchestration with separate report-generation and email activities. This meets the workflow need without introducing a separate messaging platform for the expected volume. As part of this solution, the report-generation activity uploads the PDF to the `report-files` Blob container and the email activity downloads it. Blob Storage is an artifact handoff within this decision, rather than a separate ADR.

## Consequences

* The workflow has persisted execution state and a status response for callers.
* The activities can access the same PDF without relying on a shared local file system.
* The service depends on Durable Functions storage and Blob Storage.
* PDF retention, cleanup, and access controls need an operational policy.
* Failure handling and orchestration replay behavior need explicit verification.

## Implementation evidence

The [orchestrator](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/orchestrator_reporting.js) starts both activities and returns a status response. The [report service](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/shared/utils/reportService.js) uploads the PDF. The [email activity](https://github.com/TQKNG/automation/blob/27045ec413f88cd2227ab08e18ec76db3e8e3d34/src/functions/activity_sendEmail.js) downloads the PDF before sending it.

## Revisit when

Reconsider the orchestration or artifact handoff if report volume, workflow complexity, retention requirements, or recovery requirements exceed this approach.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.