Acme Marketing Architecture

8. Orchestration, extraction and transformation compute

8. Orchestration, extraction and transformation compute

Date: 2026-10-26

Status

Proposed


Problem

Three kinds of work with three failure modes (AP-02): orchestration (schedules, dependencies, parameters), extraction (API calls, rate limits, auth, a public endpoint for webhooks) and transformation (Delta MERGE, SCD2, star schema, the gate). Fabric offers pipelines, copy jobs, Spark and Python notebooks, User Data Functions and an Apache Airflow job. Azure offers Functions (including Durable), Container Apps and Logic Apps. The team is small and assumed to be .NET-literate.


Decision

Concern Choice Notes
Orchestration Fabric Data Factory pipelines Metadata-driven: a parent pipeline reads the source registry and watermark tables, fans out per object, calls the extractor, then the Silver and Gold notebooks, then the relay. Schedules per freshness tier. Retries and timeouts per activity. Run ids flow into the ledger.
Salesforce extraction Fabric copy activity landing incremental windows and the bulk history as files for the Bronze loader Native connector, no code. Authenticates with an organisational-account consent held in the Fabric connection (ADR 10). Landing as files keeps Salesforce on the same dedupe and provenance path as every other source.
HubSpot and Google Ads extraction Azure Functions, .NET 10 isolated worker, Flex Consumption plan Invoked by the pipeline through a Web activity with a window parameter: synchronous only when the expected run is under about 3 minutes (a Web activity times out after 1 minute by default and 10 at most; an HTTP-triggered Function answers within 230 s), otherwise the async request-reply pattern (start, status endpoint, complete; the Web activity then waits up to 7 days; for a partitioned run the status endpoint returns the aggregate over partitions, landed, partial, failed or running, with the per-partition rows, and a retry targets only the failed partitions under a new run_id, finding C35); catch-up, reload and historical runs are always async; a notebook activity has no such limit (finding C25). Writes raw pages as files to the OneLake landing folder through the ADLS Gen2 API using the Function's managed identity; a Bronze notebook promotes files to Delta. Keeps its own run state (page cursors, nudge log, delivery log, requests used) in Azure Table Storage in the Function's storage account, because a Function cannot write Delta tables; a notebook mirrors that state into the control schema hourly. Flex Consumption gives scale-to-zero, VNet integration and long-enough execution for paged extracts.
HubSpot webhook receiver Azure Function (HTTP trigger) behind the same plan, optionally fronted by API Management Validates the v3 signature against the configured public URL (behind API Management the Function sees a rewritten URL), maps subscriptionType and objectTypeId to the registry object through object_registry.webhook_object_type (finding C24), returns 200 in milliseconds, enqueues ids to the session-enabled Service Bus queue ingest-nudges; a session-triggered Function receives batches (minMessageBatchSize 100, maxBatchWaitTime 10 s, at most half the lock duration, finding C17) and batch-reads and lands them. This component cannot live inside Fabric: third-party webhooks need a public, unauthenticated-by-Entra endpoint.
Transformation Fabric notebooks Python (single-node) notebooks for objects below a few million rows per run; Spark notebooks for the HubSpot events tables and the historical backfill. Same code base, parameterised by (object, window, mode). Gold is two jobs: a 15-minute Tier 1 event job (Python, rules over the Silver change feed) and the star build (Spark; hourly for Tier 1 facts, nightly for the rest). Both run in the restricted workspace and write across workspaces into lh_gold. The Bronze loader runs there too and is the only identity allowed to call the token vault.
Relay and reconciliation Fabric notebooks scheduled by the pipeline Relay reads CDF and publishes to Service Bus; reconciliation calls source count endpoints through the extractor Functions.
Rate limiting across callers A static share of the portal budget per caller, one in-flight instance per share HubSpot limits are per app and per account, and several processes draw on them: the incremental extractor, the nudge worker, the reconciler and sweep, the historical loader. Each runs an in-process paced limiter that admits at most its configured share in any rolling 10-second window (one-second replenishment of a tenth of the share, or a sliding window: a bucket of capacity = share with a 10-second refill admits almost twice the share, WP0b finding C12; the behaviour is specified, not the library, and the clock is injectable so the shipped limiter is testable, finding C22) (on Professional/Enterprise: 120, 40 and 10 of the 190 requests per 10 s; 3, 0 and 1 of the 5 searches per second; the general shares halve on Free/Starter to 60, 20 and 5; the search shares stay, since the 5 per second is per account and tier-independent; associations fall to 60 of the 100 on Free/Starter; shares are rows in control.rate_share) and exactly one instance of each is in flight: the pipeline runs HubSpot objects sequentially, ingest-nudges is session-enabled with one session per portal, the reconciler and the loader are scheduled serially; the extractor's in-run window counts draw on its own search share and the reconciler's counts on its own (finding C32). The daily allowance is the shared api_budget ledger with a 10% reserve. A distributed limiter (Azure Cache for Redis) is the fallback only if the WP0b PoC shows a share starving; it is not in the baseline. Figures and sources in the PoC brief.
Long-running backfill Pipeline loop over windows, each a normal run No Durable Functions needed; the ledger is the state.

Decision pending: extractor runtime (architect's direction, 2026-10-26)

The delivery team is not yet staffed; developers will be found along the way. The runtime for the HubSpot and Google Ads extractors is therefore not decided by team skills but by a pair of throwaway PoCs built once the ADRs are finalised (roadmap WP0b). Until then this record keeps .NET on Azure Functions as the leading option. Whatever the outcome, the webhook receiver, the nudge worker and the webhook dispatcher stay on Azure Functions (public endpoint, queue and session triggers): a Fabric notebook cannot be triggered by a Service Bus message, so a notebook-only nudge path would drain on a schedule and lose the within-a-minute nudge (WP0b finding C3, decided by the Lead Architect). The adapter contract, landing layout and ledger do not change.

Criterion .NET 10 on Azure Functions (Flex Consumption) Fabric Python notebook (single node, requests)
Public webhook endpoint and queue trigger Native Not possible; the receiver and the nudge worker stay on Functions either way
Long paged extracts Async start, poll, complete; timeouts to manage Natural: a notebook run is a job; no HTTP timeout
Cold start and 15-minute cadence Seconds; scale to zero Python kernel start-up about 5 s (Microsoft Learn, finding C14); high-concurrency session reuse is not available to the Python kernel
Rate limiting and retries Paced per-caller limiter with an injectable clock; System.Threading.RateLimiting is an option, not a requirement (its TokenBucketRateLimiter takes no TimeProvider); Polly for retries Same logic in Python (tenacity or hand-rolled); a notebook run is one process, so the share holds without coordination
Landing writes DataLake SDK with managed identity Direct Files/ path, no extra identity
Run state Table Storage plus the state-sync notebook Written straight to the control schema in Delta through delta-rs, one moving part fewer; delta-rs cannot write tables with deletion vectors (on by default in Fabric Spark Runtime 2.0), so those control tables are created with deletion vectors off and have one writer engine each; the extractor notebook's default lakehouse is the landing lakehouse, so it writes control through an abfss:// path with a storage token from notebookutils.credentials.getToken in delta-rs storage_options (finding C15, live check in WP0b)
Secrets Key Vault via managed identity Key Vault via the workspace identity and notebookutils.credentials
Testing and CI Unit tests, contract tests, standard .NET pipelines Notebook testing is weaker; Environment items are limited for the Python kernel, so the adapter ships as a wheel installed with %pip from Files/ or notebook resources, with inline installation enabled for pipeline runs (finding C14, live check in WP0b)
Observability Application Insights, structured logging Fabric monitoring hub and notebook logs; less granular
Cost Near zero at idle; per execution Consumes capacity CU-seconds while the session runs (included in the F SKU)
Deployment Azure DevOps or GitHub Actions Fabric Git integration and deployment pipelines
Skills to hire .NET plus Azure Python plus Fabric

PoC scope (both variants, same acceptance test; detail in the WP0b PoC brief): the HubSpot adapter contract for contacts, incremental search with keyset paging under the 10,000 cap (finding C2 replaced the window splitting of the first brief), batch read, associations batch read, landing files with manifest, cursor commit per page, reconciliation count, the per-caller budget shares with the nudge worker running concurrently. Measured: engineering days; end-to-end latency for a 15-minute window; behaviour under a forced 10-second 429 and a simulated daily-limit error; cost per day (Function execution charges versus CU-seconds); lines of operational code (state, retries, secrets, limiter); testability (unit tests runnable in CI); requests per 1,000 contacts; whether any budget share starved. At the architect's request (2026-10-26) each variant also implements a Google Ads slice (campaign snapshot, trailing-window performance by date through SearchStream, change_event under the 10,000-row cap), measured for reuse of the adapter skeleton; brief §9.

Decision rule: pick the variant that meets the latency target at lower operational code and cost; ties go to the one the hired team can maintain. The outcome moves this record to Accepted and sets the default for every future built adapter (ADR 4).

Interim evidence (WP0b PoC, four rounds on 2026-10-26, results): both variants pass the acceptance tests against fake portals (85 pytest and 57 xUnit tests, re-run by the architecture session); request counts are identical and extraction logic is within 13% (1,177 lines in Python against 1,045 in .NET), so the runtime barely changes the hard part; the notebook variant has about 1,405 operational lines against about 1,651 plus an unbuilt state-sync notebook for Functions, but it does not remove Functions from the HubSpot path (receiver and nudge worker stay there) and carries Delta-writer and packaging caveats; the .NET variant needs the async invocation path for anything over about 3 minutes (one incremental window stays synchronous; catch-up, reload and historical go through the extract-requests queue with a status endpoint). The 36 deviations the PoC raised were decided on 2026-10-26 and are applied in the documents and in both variants. Still pending a live run before this record moves: latency and CU cost of a 15-minute notebook run against Function cost; the Python-kernel packaging route; delta-rs writes to lh_silver over abfss; the hs_object_id GT filter and after semantics; the daily-limit 429 body; the search double charge; the historical URL length.


Considered Options

Option Summary Pros Cons
✅ Fabric pipelines + copy activity + .NET Functions + notebooks Each concern on the tool built for it Native where native exists; public endpoint where needed; transforms next to the data Two runtimes (Fabric, Functions) to deploy and observe; cross-service identity setup
Everything in Fabric (Python notebooks for extraction) No Azure compute One platform, one bill, one monitoring hub Cannot receive third-party webhooks; notebook start-up latency for frequent small polls; capacity consumed by API waiting time
Everything in Azure Functions (Durable) Durable orchestrations drive extraction and call Spark Code-first, unit-testable end to end Re-implements scheduling, monitoring and lineage that Fabric pipelines already give; two orchestrators if any pipeline exists
Azure Data Factory outside Fabric Mature, same connectors Familiar Duplicate of Fabric Data Factory with a separate bill and no OneLake-native integration
Apache Airflow job in Fabric Python DAGs Flexible More to learn and operate; no advantage over pipelines for a dozen DAGs
Materialized Lake Views instead of Gold notebooks Declarative Spark SQL with lakehouse-managed refresh No notebook code for simple aggregates; incremental refresh where eligible Cannot run the day-level replaceWhere rebuild or the insert-if-absent MERGE; cannot write across workspaces. Kept as an option for aggregates built from already-gated Gold tables (ADR 2).
Logic Apps for extraction (Consumption or Standard) Designer-first connectors (HubSpot, Salesforce exist); Standard runs the workflows on the Azure Functions host on a Workflow Standard plan with built-in connectors, local debugging and VNet Fast to click together; Standard adds Data Mapper, XSLT and Liquid without an Integration Account, which suits XML and EDI integrations Consumption bills every action, so paged extracts and loops explode in cost. Standard removes that but is the same Functions host at a fixed price (WS1 about 158 EUR a month in West Europe, live 2026-10-26, against about 20 to 39 EUR for Flex Consumption at launch demand, cost estimate §2b) with no scale to zero; stateful workflows checkpoint every action to storage; managed connectors are still billed per action (about 0.00016 EUR); inline custom code shares the host's memory, scaling and lifecycle with the workflows; network isolation is not a differentiator, since Flex Consumption and Premium Functions offer VNet integration and private endpoints. Keyset paging, the per-caller budget, the breaker and the landing contract are code either way, so the designer would add a layer without removing one; a hybrid (Logic Apps for connectors, Functions for compute) would be the Azure Integration Services pattern, but the orchestration here is already Fabric pipelines. Durable Functions is the code-first orchestration alternative, the row above. Rejected for the adapters; revisit only for a future source that is XML or EDI based or whose only connector is a Logic Apps managed connector
dbt core models for Silver and Gold Declarative SQL models with tests and lineage through dbt-fabric One model per source mapping; built-in tests and docs Another tool and runtime to operate; the gate, day-level replaceWhere rebuilds and cross-workspace writes need notebooks anyway. Revisit when source mappings exceed about thirty.

Consequences

Positive:

Negative / Trade-offs:

Risks: | Risk ID | Description | Impact (E/H/M/L) | Mitigation | |---------|-------------|------------------|------------| | R1 | Web activity or HTTP Function timeout on long extracts | M | Async pattern (start, poll status, complete) for anything expected over about 3 minutes; windows capped by window_size_minutes and max_windows_per_run | | R2 | Notebook start-up eats into 15-minute cycles | L | Python kernel starts in about 5 s; Spark session reuse (high concurrency) applies to Spark notebooks only |