Skip to content

cost-analysis-export: Support multiple CSV schemas#5579

Merged
r2k1 merged 4 commits intomasterfrom
support-multiple-csv-schemas
Mar 19, 2026
Merged

cost-analysis-export: Support multiple CSV schemas#5579
r2k1 merged 4 commits intomasterfrom
support-multiple-csv-schemas

Conversation

@r2k1
Copy link
Copy Markdown
Contributor

@r2k1 r2k1 commented Jan 29, 2026

Summary

  • Add support for multiple Azure cost export CSV schemas (Legacy EA/PAYG, MCA, FOCUS)
  • Dynamically detect resource ID and date columns based on schema
  • Fix bug where missing trailing slash in storage prefix paths caused AKS export files to not be found
  • Add logging when no AKS export files are found to aid debugging

r2k1 added 2 commits January 29, 2026 20:51
Add dynamic query builder to handle different column names across:
- Legacy EA/PAYG (InstanceId, UsageDateTime, UsageQuantity, PreTaxCost)
- Modern EA 2024 (ResourceId, Date, Quantity, CostInBillingCurrency)
- MCA/MCA Partner/CSP (camelCase: resourceId, date, quantity, costInBillingCurrency)
- FOCUS (ResourceId, ChargePeriodStart, ConsumedQuantity, BilledCost)

Key changes:
- Detect ResourceID and Date columns dynamically for JOIN
- Multiply all cost/quantity columns by split fraction
- Preserve original column names in output
- Add test cases for Modern EA, MCA, and FOCUS schemas
Automatically append trailing slash to AZURE_STORAGE_AKS_DATA_PREFIX
and AZURE_STORAGE_COST_EXPORT_PREFIX if missing. Also add logging
when no AKS export files are found to aid debugging.
@r2k1 r2k1 requested review from a team, charleswool and Copilot January 29, 2026 08:01
@r2k1 r2k1 requested review from a team and palma21 as code owners January 29, 2026 08:01
@r2k1 r2k1 requested a review from juan-lee January 29, 2026 08:01
@r2k1 r2k1 changed the title Support multiple Azure cost export CSV schemas cost-analysis-export: Support multiple CSV schemas and fix prefix bug Jan 29, 2026
@r2k1 r2k1 changed the title cost-analysis-export: Support multiple CSV schemas and fix prefix bug cost-analysis-export: Support multiple CSV schemas Jan 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the cost analysis export tool to support multiple Azure cost export CSV schemas, making it compatible with Legacy EA/PAYG, MCA (Microsoft Customer Agreement), and FOCUS (FinOps Open Cost and Usage Specification) formats. The implementation dynamically detects the schema by inspecting column names rather than requiring explicit configuration.

Changes:

  • Added dynamic schema detection that identifies resource ID and date columns from a list of known variants across different Azure billing schemas
  • Fixed a bug where missing trailing slashes in storage prefix paths caused file discovery failures
  • Added logging to aid debugging when no AKS export files are found

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
examples/cost-analysis-export/main.go Implements dynamic column detection, adds prefix path normalization in config validation, adds file processing logging, and builds SQL queries dynamically based on detected schema
examples/cost-analysis-export/main_test.go Updates test assertions to check for column presence rather than exact order/content, adds comprehensive test cases for Modern EA, MCA, and FOCUS schemas

Comment thread examples/cost-analysis-export/main.go
r2k1 added 2 commits February 4, 2026 11:05
MCA cost exports use MM/DD/YYYY format while AKS exports use YYYY-MM-DD,
causing INNER JOIN to return zero rows. Added date normalization during
CSV import to convert all dates to YYYY-MM-DD format.
Helps debug issues when join returns empty results.
Copilot AI review requested due to automatic review settings February 4, 2026 00:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread examples/cost-analysis-export/main.go
Comment thread examples/cost-analysis-export/main.go
Comment thread examples/cost-analysis-export/main.go
Comment thread examples/cost-analysis-export/main.go
Comment thread examples/cost-analysis-export/main.go
@r2k1 r2k1 merged commit f75f0af into master Mar 19, 2026
9 checks passed
@r2k1 r2k1 deleted the support-multiple-csv-schemas branch March 19, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants