← Building a Fleet-Scale Azure Platform
05 / 09 Technical field note

Building a SOC 2-Ready Billing Automation Platform on Azure

How governed ingestion, a protected PostgreSQL system of record, and secure APIs create a trustworthy financial data platform.

AzurePostgreSQLAPI ManagementSOC 2

Billing data is one of those systems that looks simple from the outside and becomes complicated very quickly at enterprise scale.

At a small scale, billing automation can look like a scheduled file import, a few reports, and a database table. At a larger scale, it becomes a governed data platform. The system has to ingest data reliably, preserve accuracy, support daily and monthly reporting, protect financial records from tampering, expose secure API access, and provide enough auditability to satisfy compliance requirements.

This article walks through a billing automation platform I developed to process Microsoft billing exports from multiple worldwide locations, normalize the data into PostgreSQL, and expose secure API access through Azure API Management. The goal was not only to automate billing ingestion, but to build a reliable, secure, and auditable billing data platform that could support enterprise operations at scale.

Where This Fits in the Platform Story

This billing automation platform was not a standalone reporting tool. It was a natural extension of the broader fleet governance platform.

After building the governance, deployment, and automation foundation, the next challenge was creating a trusted financial data layer. Infrastructure governance tells you what exists, how it is configured, and whether it is compliant. Billing governance tells you what that infrastructure costs, how spend changes over time, and whether financial data can be trusted for reporting, customer visibility, and operational decision-making.

The billing automation platform became the system that processed global Microsoft billing exports, normalized them into PostgreSQL, and exposed secure, SOC 2–ready API access for daily and monthly cost reporting.

That made the platform more than an operational governance system. It became a controlled data platform that connected infrastructure state, financial data, compliance controls, and API-driven access into one enterprise capability.

This distinction matters because billing data is not just another dataset. It is financially material, customer-sensitive, and audit-relevant. The same engineering principles used for infrastructure governance — idempotency, controlled access, automation, auditability, and least privilege — had to be applied to billing ingestion and API access as well.

The Problem: Billing Data at Global Scale

The platform needed to process daily and monthly Microsoft billing exports that were delivered into Azure Storage. These exports arrived from 13 worldwide locations, each representing a different billing source, geography, or operational scope.

The challenge was not simply moving files from storage into a database. The system needed to solve several problems at once:

  • Process daily and monthly billing drops consistently.
  • Support billing exports from multiple global locations.
  • Load large billing datasets into PostgreSQL accurately.
  • Make billing data available through a secure API.
  • Optimize queries for fast daily and monthly lookups.
  • Protect billing data from unauthorized modification.
  • Maintain extensive audit trails.
  • Enforce network, identity, and role-based access controls.
  • Support SOC 2 compliance expectations around security, availability, confidentiality, and processing integrity.

Billing data is highly sensitive. It drives financial reporting, customer-facing cost visibility, operational analysis, and internal decision-making. If the data is late, incorrect, inaccessible, or modified without traceability, the business impact is immediate.

That is why the platform was designed as a controlled financial data pipeline rather than a simple import job.

High-Level Architecture

The architecture follows a layered model.

Microsoft billing exports are delivered into Azure Storage. Azure Data Factory detects and processes each billing drop. Billing files from all 13 worldwide locations are validated, transformed, and loaded into PostgreSQL. PostgreSQL stores the normalized billing data and also serves as the backend data store for the billing API.

Azure API Management exposes controlled API access. A Web Application Firewall protects the API edge. Access is restricted by approved IP addresses and role-based access controls. PostgreSQL auditing, permissions, and data integrity controls help protect the data from unauthorized change. Logging and audit trails support SOC 2 compliance and operational review.

At a high level, the platform includes:

  1. Azure Storage as the billing export landing zone.
  2. Azure Data Factory for ingestion and transformation.
  3. PostgreSQL for normalized billing storage and API query access.
  4. Azure API Management for governed API exposure.
  5. Web Application Firewall protection at the edge.
  6. IP allowlisting for restricted network access.
  7. RBAC controls for identity-based authorization.
  8. PostgreSQL auditing and tamper-resistant controls.
  9. Monitoring and logging for operational and compliance evidence.

This architecture separates ingestion, storage, access, and compliance controls so that each layer has a clear responsibility.

Why Azure Data Factory Was Used for Billing Ingestion

Azure Data Factory was a strong fit for the ingestion layer because the platform needed to orchestrate recurring file-based data movement across multiple global sources.

The system processes both daily and monthly billing drops. Daily files provide near-current operational visibility, while monthly files support reconciliation, financial reporting, and authoritative billing close processes.

Using Azure Data Factory allowed the platform to:

  • Monitor storage locations for incoming billing exports.
  • Process billing files from multiple global locations.
  • Apply consistent transformation logic.
  • Load data into PostgreSQL using repeatable pipelines.
  • Track pipeline success, failure, and retry behavior.
  • Separate raw landing data from processed billing data.
  • Provide operational visibility into ingestion status.

At this scale, ingestion reliability matters as much as ingestion speed. A failed billing import is not just a technical error. It can delay reporting, affect customer visibility, and create downstream reconciliation issues.

Storage as the Billing Landing Zone

Azure Storage acts as the controlled landing zone for Microsoft billing exports. The storage account receives the billing drops before they are processed by Azure Data Factory.

This pattern provides an important separation of concerns. Raw billing exports are preserved as the source input, while transformed and query-ready data is loaded into PostgreSQL.

That separation is important for auditability and troubleshooting. When a billing record needs to be investigated, the platform can trace the data back to the original export, the ingestion pipeline, and the final normalized PostgreSQL record.

A good billing platform should always be able to answer three questions:

  1. Where did this billing record come from?
  2. When was it processed?
  3. Has it changed since it was loaded?

Those questions shaped the design of the ingestion and audit model.

PostgreSQL as the Billing System of Record

PostgreSQL became the backend system of record for processed billing data.

The reason was straightforward: billing queries require relational structure, indexing, aggregation, filtering, and transactional integrity. Billing data is not just a blob of usage records. It needs to be queried by subscription, customer, account, service, meter, date range, region, invoice period, resource, and other dimensions.

PostgreSQL gave the platform the ability to support:

  • Normalized billing tables.
  • Daily and monthly billing datasets.
  • Indexed query paths for common API access patterns.
  • Accurate aggregations.
  • Historical cost analysis.
  • Reconciliation workflows.
  • Data integrity controls.
  • Auditing and access control.

At enterprise scale, the difference between a billing database that merely stores data and one that can actually serve the business is query design.

Query Optimization Was a Core Engineering Focus

A major part of the project was optimizing PostgreSQL queries so that the billing API could return quick and accurate results.

Billing datasets grow quickly. Daily exports accumulate over time, monthly exports can be large, and API requests often require aggregation across wide date ranges.

Common query patterns included:

  • Daily cost by subscription.
  • Monthly cost by customer.
  • Cost by service category.
  • Cost by resource.
  • Cost by region.
  • Cost by account or billing scope.
  • Month-over-month comparisons.
  • Daily trend analysis.
  • Detailed line-item retrieval.
  • Summary views for dashboards and APIs.

To support these patterns, the platform required deliberate database design. That meant spending time on indexing strategy, date filtering, aggregation paths, query plans, API-specific access patterns, and the separation of detailed line-item queries from summary-level reporting queries.

The goal was not simply to make one query fast. The goal was to make the common billing questions fast, predictable, and accurate.

That required thinking about PostgreSQL as both a financial data store and an API backend.

API Access Through Azure API Management

Once billing data was available in PostgreSQL, the next requirement was controlled API access.

Azure API Management was used as the API gateway layer. This allowed the platform to expose billing data through managed endpoints while enforcing consistent security and operational controls.

API Management provided a clean boundary between consumers and backend services. Instead of allowing direct database access or unmanaged service calls, consumers accessed billing data through governed APIs.

This approach provided several advantages:

  • Centralized API access control.
  • Consistent authentication and authorization policies.
  • Request validation.
  • API versioning.
  • Logging and traceability.
  • Separation between external consumers and internal backend implementation.
  • A controlled path for future API expansion.

For billing data, this kind of boundary is critical. Financial data should not be accessed through ad hoc database connections or unmanaged scripts. It should be exposed through a governed API surface with clear access rules.

Protected by WAF, IP Restrictions, and RBAC

The API was also protected by a Web Application Firewall and restricted to specific approved IP addresses.

This created multiple layers of access control:

  • Network-level restriction through IP allowlisting.
  • Edge protection through WAF.
  • API-level policy enforcement through Azure API Management.
  • Identity and authorization through RBAC.
  • Database-level controls inside PostgreSQL.

No single control was treated as sufficient by itself. The design used defense in depth.

For example, even if a consumer could reach the API endpoint from an approved network location, they still needed the correct identity and role-based permissions. Even if an identity had API access, the backend still enforced controlled access patterns. Even if data existed in PostgreSQL, it was protected against unauthorized modification.

This layered model is essential for billing platforms because the data is sensitive, regulated, and financially material.

Protecting PostgreSQL From Tampering

One of the most important design considerations was protecting billing data from tampering.

Billing platforms need strong guarantees around data integrity. A billing record should not be silently changed after ingestion. Any correction, reload, or adjustment should be traceable.

The PostgreSQL design included controls to protect the integrity of the data, including restricted write paths, controlled ingestion accounts, role separation, and extensive auditing.

The platform was designed so that billing data changes could be attributed, reviewed, and investigated. This is especially important in a SOC 2 context, where the organization must demonstrate that systems handling sensitive data are controlled, monitored, and auditable.

The principle was simple: billing data should be easy to query, but difficult to alter without authorization and traceability.

Designing for SOC 2 Compliance

SOC 2 readiness was built into the platform design rather than added afterward.

That influenced decisions across ingestion, storage, API access, auditing, database permissions, and operations.

Key SOC 2-aligned design principles included:

  • Controlled access to billing data.
  • Least-privilege permissions.
  • Separation of duties between ingestion, API access, and administration.
  • Audit logging for data access and operational events.
  • Protection against unauthorized data modification.
  • Secure API exposure.
  • Network restrictions for sensitive endpoints.
  • Traceability from raw billing exports to processed records.
  • Monitoring of pipeline execution and failures.
  • Evidence generation for compliance reviews.

SOC 2 is not just about having security tools in place. It is about being able to prove that the platform behaves in a controlled and repeatable way.

For this billing automation platform, that meant designing evidence into the system. Pipeline runs, data loads, access events, administrative actions, and database changes needed to be visible and reviewable.

Daily and Monthly Billing Workflows

The platform supports both daily and monthly billing workflows because each serves a different operational purpose.

Daily billing data supports near-real-time visibility. It helps teams understand current spend, detect unusual trends, and provide timely reporting.

Monthly billing data supports reconciliation and financial close. It is more authoritative and is often used for reporting, invoicing, and long-term analysis.

The platform had to support both without confusing the two. Daily data needed to be available quickly, while monthly data needed to be loaded accurately and preserved for historical reporting.

That required clear processing rules, date handling, and data modeling so consumers could understand which dataset they were querying and why.

Why This Matters for Enterprise Governance

Infrastructure governance and billing governance are closely related.

A governance platform can tell you which resources exist, where they are deployed, whether they follow policy, and whether they have drifted from the approved state. A billing platform adds the financial dimension: what those resources cost, how spend trends over time, and where cost accountability should be applied.

When those capabilities are connected through a secure API layer, the organization gains a much richer operating model.

Teams can move beyond static reports and start answering practical questions:

  • Which subscriptions are driving the largest cost changes?
  • Which services are increasing month over month?
  • Which resources need cost review?
  • Which customers or environments are generating unexpected spend?
  • Which billing records support a specific financial report?
  • Which API consumers accessed billing data and when?
  • Which data loads contributed to a specific reporting period?

That is the real value of a billing automation platform. It does not just automate ingestion. It creates a trusted financial data foundation for governance, reporting, and decision-making.

Lessons Learned

The biggest lesson from this project is that billing automation is not just a data pipeline. It is a financial control system.

When billing data becomes part of operational reporting, customer visibility, and executive decision-making, the platform must be designed with the same discipline as any other critical enterprise system.

Several lessons stood out.

First, ingestion reliability is foundational. If the daily and monthly billing drops are not processed consistently, everything downstream becomes questionable.

Second, query performance must be designed early. Billing datasets grow quickly, and slow queries become a major operational problem once APIs and dashboards depend on them.

Third, API access needs strong governance. Billing data should be exposed through controlled endpoints, not direct database access.

Fourth, compliance requirements should influence architecture from the beginning. SOC 2 controls are much easier to support when auditing, access control, and traceability are built into the platform design.

Finally, tamper protection matters. Billing data is financially sensitive, and the platform must make unauthorized changes difficult, detectable, and attributable.

Final Thoughts

This billing automation platform was built to solve a real enterprise problem: how to process global Microsoft billing exports reliably, store them in a performant relational backend, and expose the data securely through governed API access.

The final architecture combined Azure Storage, Azure Data Factory, PostgreSQL, Azure API Management, WAF protection, IP restrictions, RBAC, and extensive auditing into a controlled billing data platform.

At small scale, billing automation can be treated as a reporting convenience. At enterprise scale, it becomes a trust system.

The value of the platform was not only that it automated billing ingestion. The value was that it created a secure, auditable, SOC 2–ready foundation for billing data access, reporting, financial governance, and enterprise decision-making.

Architecture depth + engineering leadership

Building platforms enterprises trust at scale.