Skip to main content

Creating Azure Billing Exports

If you don't have Cost Management exports configured yet, follow this guide to create them. CXM requires access to these exports for cost analysis and FinOps recommendations.

Recommended Format

We recommend using FOCUS format (or Parquet with Snappy compression) for optimal compatibility and reduced storage costs.

Supported Billing Account Types

CXM supports Azure accounts that can create Cost Management exports:

Account TypeSupportedNotes
EA (Enterprise Agreement)YesCan export at billing account or subscription level
MCA (Microsoft Customer Agreement)YesCan export at billing profile or subscription level
Pay-as-You-Go (MOSP)YesSubscription-level exports only
CSP (Cloud Solution Provider)PartialDepends on partner configuration

How to Check Your Account Type

  1. Go to Azure Portal
  2. Search for "Cost Management + Billing"
  3. Look at Billing scopes in the left menu
  4. Your account type is shown next to each billing scope
EA and MCA Customers

You can create exports at the billing account level to capture costs across all subscriptions in one export - simpler than per-subscription exports.

Export Formats

Azure supports two export dataset types:

FormatDescriptionBest For
FOCUSFinOps Open Cost and Usage Specification - standardized cross-cloud formatMulti-cloud environments, future-proof
Legacy (ActualCost/AmortizedCost)Azure-native formatAzure-only environments
CXM Recommendation

Use FOCUS format if available for your account type. It provides standardized column names that work across AWS, Azure, and GCP, making multi-cloud analysis easier.

Prerequisites

  • Azure Subscription or Billing Account with Cost Management access
  • Storage Account to store the export files (or permissions to create one)
  • Permissions:
    • Subscription exports: Cost Management Contributor on the subscription
    • Billing account exports: Billing Account Contributor (EA) or Billing Profile Contributor (MCA)

Step 1: Navigate to Cost Management

  1. Go to Azure Portal
  2. Search for "Cost Management" in the top search bar
  3. Select Cost Management from the results

Step 2: Create Export

  1. In the left menu, click Exports
  2. Click + Add to create a new export

Step 3: Configure Export Settings

Fill in the export configuration:

SettingRecommended ValueDescription
Namecxm-daily-exportA descriptive name for the export
MetricCost and usage (FOCUS)Standardized format (preferred)
Export typeDaily export of month-to-date costsCaptures daily cost updates
Dataset versionLatest availableUse the most recent version
Start dateToday's dateWhen to start exporting
FOCUS vs Legacy

If "Cost and usage (FOCUS)" is not available, select "Actual cost" or "Amortized cost" instead. FOCUS availability depends on your billing account type.

Step 4: Configure Storage

  1. Storage account: Select an existing storage account or create a new one
  2. Container: Create or select a container (e.g., cost-exports)
  3. Directory: Optional path prefix (e.g., daily)

Step 5: Configure Format (Important)

Under File format and compression:

SettingRecommended Value
FormatParquet
CompressionSnappy
File partitioningOn (recommended for large datasets)
Overwrite dataOn (keeps only latest data)
Why Parquet?

Parquet is a columnar format optimized for analytics:

  • 70% smaller file sizes compared to CSV
  • Faster processing with tools like Spark, Synapse, or Fabric
  • Snappy compression provides fast decompression with good compression ratios

Step 6: Create and Run

  1. Click Create
  2. After creation, click Run now to generate the first export immediately
  3. Subsequent exports will run automatically based on your schedule

Option 2: Azure CLI

Create a daily Parquet export using the Azure CLI:

# Set your variables
SUBSCRIPTION_ID="your-subscription-id"
STORAGE_ACCOUNT_ID="/subscriptions/$SUBSCRIPTION_ID/resourceGroups/your-rg/providers/Microsoft.Storage/storageAccounts/yourstorageaccount"
CONTAINER_NAME="cost-exports"

# Create the export
az costmanagement export create \
--name "cxm-daily-export" \
--type "ActualCost" \
--scope "/subscriptions/$SUBSCRIPTION_ID" \
--storage-account-id "$STORAGE_ACCOUNT_ID" \
--storage-container "$CONTAINER_NAME" \
--timeframe "MonthToDate" \
--recurrence "Daily" \
--recurrence-period-from "$(date -u +%Y-%m-%dT00:00:00Z)" \
--recurrence-period-to "$(date -u -d '+10 years' +%Y-%m-%dT00:00:00Z)" \
--schedule-status "Active" \
--format "Parquet"

Run the export immediately:

az costmanagement export run \
--name "cxm-daily-export" \
--scope "/subscriptions/$SUBSCRIPTION_ID"

Option 3: Terraform (CXM Module)

If you're using the CXM Terraform module, you can have it create FOCUS exports automatically:

Experimental Feature

Automatic FOCUS export creation via Terraform is experimental. The Azure Cost Management export API may change, and FOCUS format support varies by billing account type.

Recommended approach: Create exports manually using Azure Portal, then point the Terraform module to your existing storage account.

module "cxm_integration" {
source = "github.com/cxmlabs/terraform-azure-cxm-integration"

# Enable billing export access AND creation
enable_billing_export_access = true

# Create a new storage account and FOCUS exports (experimental)
billing_export_create_storage_account = true
billing_export_create_cost_exports = true
billing_export_format = "focus" # FOCUS format (default)

# ... rest of configuration
}

The module uses the azapi provider to create FOCUS exports, which provides:

  • FOCUS format with Parquet and Snappy compression
  • Daily partitioned exports for efficient querying
  • Automatic role assignments for CXM to read the exports
Already have exports?

If you already have Cost Management exports configured, just point the module to your existing storage account and skip export creation:

billing_export_storage_account_name   = "your-existing-storage"
billing_export_storage_resource_group = "your-rg"
billing_export_create_cost_exports = false # Don't create new exports

Standalone Terraform Resource

If you're not using the CXM module, you can create exports with the standard azurerm provider (legacy format only):

resource "azurerm_subscription_cost_management_export" "cxm" {
name = "cxm-daily-export"
subscription_id = "/subscriptions/${data.azurerm_subscription.primary.subscription_id}"
recurrence_type = "Daily"
recurrence_period_start_date = formatdate("YYYY-MM-DD'T'00:00:00'Z'", timestamp())
recurrence_period_end_date = formatdate("YYYY-MM-DD'T'00:00:00'Z'", timeadd(timestamp(), "87600h"))

export_data_storage_location {
container_id = azurerm_storage_container.exports.id
root_folder_path = "daily"
}

export_data_options {
type = "ActualCost"
time_frame = "MonthToDate"
}
}
FOCUS via Terraform

The azurerm provider doesn't natively support FOCUS exports. To create FOCUS exports via Terraform outside of the CXM module, you would need to use the azapi provider to call the Azure REST API directly.

Export Types Explained

FOCUS (FinOps Open Cost and Usage Specification) is a standardized format maintained by the FinOps Foundation:

BenefitDescription
Cross-cloud compatibilitySame column names across AWS, Azure, GCP
Includes all cost typesActual and amortized costs in one export
Future-proofIndustry standard, continuously improved

Legacy Formats

If FOCUS is not available, use these Azure-native formats:

Export TypeDescriptionUse Case
ActualCostActual billed costs including purchasesPrimary cost analysis
AmortizedCostCosts with reservation purchases spread over timeReservation ROI analysis
UsageUsage quantities without costsResource utilization analysis
CXM Recommendation
  • First choice: FOCUS format (single export covers all needs)
  • Alternative: Create both ActualCost and AmortizedCost exports for complete coverage

Backfilling Historical Data

To analyze historical costs, you can backfill up to:

  • 13 months from the Azure Portal
  • 7 years using the REST API

Backfill via Portal

  1. Go to your export in Cost Management > Exports
  2. Click on the export name
  3. Click Export historical data
  4. Select the date range to backfill
  5. Click Export

Verify Your Export

After creating the export:

  1. Wait a few minutes for the first export to complete
  2. Navigate to your storage account
  3. Open the container you specified
  4. Verify that Parquet files are being created

Expected file structure:

cost-exports/
└── daily/
└── cxm-daily-export/
└── 20250108-20250108/
└── part-00000.snappy.parquet

Next Steps

Once your exports are configured:

  1. Note the storage account name and resource group
  2. Continue with Terraform Setup or Manual Setup
  3. CXM will automatically read the export files once connected

Troubleshooting

Export not running

  • Verify the export status is Active
  • Check that the storage account is accessible
  • Ensure you have Cost Management Contributor permissions

Empty or missing files

  • New exports may take up to 24 hours to populate
  • Click Run now to trigger an immediate export
  • Check the export run history for errors

Permission denied on storage

  • Ensure the Cost Management service has write access to the storage account
  • The export creation wizard typically handles this automatically

References