Skip to main content
CloudCostChefs Sustainability Tools

Azure Carbon Emissions Data Collector

Professional PowerShell script for collecting Azure carbon emissions data across single or multiple subscriptions. Generate CSV reports optimized for sustainability dashboards with comprehensive error handling and multi-authentication support.

Multi-Subscription Support
CSV Dashboard Export
Enterprise Authentication
Rate Limit Handling
Blaze
Blaze says:Carbon data takes about 19 days after month-end to land in Azure's API. Schedule your reports for the 20th and you'll never chase empty datasets again.

Carbon Data Collection

Retrieve comprehensive carbon emissions data from Azure's Carbon Optimization API with support for all report types and scopes.

Dashboard-Ready Export

Generate CSV files optimized for Power BI, Tableau, and other dashboard tools with proper data formatting and structure.

Enterprise Authentication

Multiple authentication methods including service principals, Azure CLI, and PowerShell contexts for any environment.

Standard collection workflow

Structured quick-reference sections for prerequisites, installation, usage, and troubleshooting.

Prerequisites

  • PowerShell 5.1+ (Windows PowerShell or PowerShell Core)
  • Azure authentication via Azure CLI, Azure PowerShell, or Service Principal
  • Azure permissions including Carbon Optimization Reader role
  • Internet access to Azure Management APIs

Data freshness

Carbon datasets can lag month-end by ~19 days. Schedule recurring pulls after the 20th to avoid empty/incomplete reports.

Supported report types

Report typeBest forTypical consumer
ItemDetailsReportDetailed carbon analysis and drill-downFinOps / sustainability analysts
MonthlySummaryReportMonth-over-month trendsLeads and reporting dashboards
Overall SummaryHigh-level footprint overviewExecutives / sustainability program owners
Top Items Monthly / SummaryPrioritizing highest emittersOptimization teams

Use summary reports for dashboards and item-level reports for remediation planning.

Standard collection workflow

  1. 1Start with a single subscription run to validate authentication and output formatting.
  2. 2Scale to `-AllSubscriptions` only after confirming performance expectations and role assignments.
  3. 3Use explicit `-StartDate`, `-EndDate`, and `-ReportType` for repeatable monthly reporting.
  4. 4Store CSV output in a stable folder for Power BI/Tableau ingestion and trend tracking.
PowerShell
.\\Get-AzureCarbonEmissions.ps1 -SubscriptionId "12345678-1234-1234-1234-123456789012"
PowerShell
.\\Get-AzureCarbonEmissions.ps1 -AllSubscriptions -GetFullDataset
PowerShell
.\\Get-AzureCarbonEmissions.ps1 -SubscriptionIds @("sub1-guid","sub2-guid") -StartDate "2024-01-01" -EndDate "2024-03-31" -ReportType "ItemDetailsReport" -OutputPath ".\\Q1-2024-Carbon-Analysis"

Authentication & automation patterns

ModeBest use caseNotes
Azure CLI / PowerShell contextInteractive testing and ad hoc runsFastest setup for validation
Service PrincipalScheduled reports / CI jobsUse secure secret storage; avoid plain-text secrets in scripts
AllSubscriptions + full datasetPeriodic enterprise exportsCan take 15+ minutes in large estates

CSV dashboard export

The script produces CSV output intended for sustainability dashboards and trend analysis.

OutputPrimary useDownstream tool
Monthly summary CSVTrend reportingPower BI / Tableau
Item details CSVHotspot analysisAnalyst workflows / spreadsheets
Top emitters reportPrioritizationOptimization backlogs
  • Use a consistent output path and naming convention for recurring reports.

Troubleshooting

  • If you receive empty data for a recent month, verify the date range and try again after the API data availability window.
  • If authentication fails in automation, validate service principal credentials and role assignments on target subscriptions.
  • If enterprise runs are slow, reduce concurrency or split by subscription groups before enabling full-dataset exports.

Secret handling

Do not hardcode service principal secrets in shared scripts. Use secure secret stores or pipeline secret variables.

Technical Specifications

Built for enterprise environments with comprehensive error handling, rate limiting, and multi-subscription support

Requirements

PowerShell 5.1+
Windows PowerShell or PowerShell Core
Azure Authentication
Azure CLI, PowerShell, or Service Principal
Azure Permissions
Carbon Optimization Reader role
Internet Connectivity
Access to Azure Management API

Key Features

Multi-Subscription Processing
Process single, multiple, or all accessible subscriptions
Concurrent Processing
Configurable parallel execution with rate limiting
Comprehensive Error Handling
Detailed error reporting and troubleshooting guidance
Pagination Support
Retrieve complete datasets with automatic pagination

Supported Report Types

Choose from multiple report formats to match your sustainability reporting needs

Item Details Report

Comprehensive line-item carbon emissions data for detailed analysis and drill-down reporting.

Best for: Detailed analysis

Monthly Summary

Month-over-month carbon emissions trends and summaries for executive reporting.

Best for: Trend analysis

Overall Summary

High-level carbon footprint overview across all subscriptions and time periods.

Best for: Executive dashboards

Top Items Monthly

Identify highest carbon-emitting resources and services by month for optimization targeting.

Best for: Optimization focus

Top Items Summary

Overall ranking of highest carbon-emitting resources across the entire reporting period.

Best for: Priority identification

Custom Date Ranges

Flexible date range selection for any reporting period with automatic data availability validation.

Best for: Custom reporting

Usage Examples

Real-world examples for common carbon data collection scenarios

Basic Single Subscription

Collect carbon emissions data for a single subscription using current Azure CLI authentication:

.\Get-AzureCarbonEmissions.ps1 -SubscriptionId"12345678-1234-1234-1234-123456789012"

All Accessible Subscriptions

Process all subscriptions you have access to with full dataset retrieval:

.\Get-AzureCarbonEmissions.ps1 -AllSubscriptions -GetFullDataset
Performance Warning: This can take 15+ minutes for enterprise tenants with comprehensive data.

Service Principal Authentication

Automated execution using service principal credentials for scheduled reporting:

.Get-AzureCarbonEmissions.ps1 ` -AllSubscriptions ` -TenantId"87654321-4321-4321-4321-210987654321" ` -ClientId"11111111-1111-1111-1111-111111111111" ` -ClientSecret"your-client-secret" ` -StartDate"2024-01-01" ` -EndDate"2024-01-31" ` -ReportType"MonthlySummaryReport" ` -OutputPath"C:\CarbonReports"

Custom Date Range & Report Type

Generate specific report types for custom date ranges with detailed item analysis:

.Get-AzureCarbonEmissions.ps1 ` -SubscriptionIds @("sub1-guid","sub2-guid","sub3-guid") ` -StartDate"2024-01-01" ` -EndDate"2024-03-31" ` -ReportType"ItemDetailsReport" ` -MaxConcurrentJobs 3 ` -OutputPath".Q1-2024-Carbon-Analysis"

Authentication Methods

Flexible authentication options for any environment - from interactive development to automated production

Azure CLI

Perfect for interactive development and testing. Simply run az login first.

Easy setup
Interactive authentication
Multi-tenant support

Service Principal

Ideal for automation, scheduled tasks, and CI/CD pipelines. Provides non-interactive authentication.

Automated execution
Scheduled reporting
CI/CD integration

Azure PowerShell

Fallback option using existing Azure PowerShell context. Great for PowerShell-heavy environments.

PowerShell native
Context reuse
Seamless integration

Performance & Best Practices

Optimize your carbon data collection with these CloudCostChefs recommendations

Performance Optimization

Rate Limiting

Keep MaxConcurrentJobs ≤ 5 to respect Azure API limits. The script includes intelligent rate limiting and retry logic.

-MaxConcurrentJobs 5

Data Availability

Carbon data is typically available 19+ days after month end. Don't expect real-time data - this is for trend analysis and historical reporting.

Large Datasets

ItemDetailsReport with GetFullDataset can return 10,000+ records and take 15+ minutes for enterprise tenants. Use appropriate report types for your needs.

CloudCostChefs Best Practices

Scheduled Reporting

Set up monthly automated runs using service principals. Schedule for the 20th of each month to ensure data availability for the previous month.

Report Type Selection

Use OverallSummaryReport for executive dashboards, MonthlySummaryReport for trend analysis, and ItemDetailsReport only when detailed drill-down is needed.

Error Handling

The script includes comprehensive error handling with detailed troubleshooting guidance. Review error messages carefully - they often indicate permission or service availability issues.

Common Issues & Solutions

Real-world troubleshooting guide for Azure Carbon Optimization API challenges

"Carbon Optimization service not found (404)"

This tenant may not have Carbon Optimization enabled. The service is not available in all Azure regions and tenant configurations.

Solution: Contact your Azure administrator to verify Carbon Optimization service availability for your tenant.

"Access denied (403)"

Missing required permissions. The Carbon Optimization API requires specific RBAC roles.

Solution: Ensure you have the"Carbon Optimization Reader" role assigned at the subscription level.

"No data available for date range"

Carbon data has a significant processing delay. Data is typically available 19+ days after month end.

Solution: Adjust your date range to request data from at least 3 weeks ago. Use historical data for trend analysis.

"Rate limit exceeded (429)"

Azure Carbon API has undocumented rate limits. The script includes automatic retry logic with exponential backoff.

Solution: Reduce MaxConcurrentJobs parameter or wait for automatic retry. Consider processing subscriptions in smaller batches.

Ready to Track Your Azure Carbon Footprint?

Download the Azure Carbon Emissions Data Collection Script and start building comprehensive sustainability dashboards today.

Part of the CloudCostChefs Cloud Optimization Kitchen • Open Source • MIT License

What to do next

Pick the path that fits where you are right now.

Trust & run-safety metadata

Key execution details for Azure Carbon Skimmer so users know what they are downloading or running before they act.

Need verification guidance? See Security & Trust and Responsible Disclosure.

Read-only / reportingGitHub sourceExplicit + inferred metadata

Maintainer

CloudCostChefs

Last Updated

July 2, 2025

Last Tested

February 23, 2026

Minimum Access

Reader access to Azure consumption/resource data used by the reporting workflow

Execution Type

GitHub-hosted reporting workflow (Azure carbon/emissions analysis)

Version

2025-07-02

SHA256 Checksum

Not published yet (recommend adding checksum for downloadable files)

Verification Notes

Source is hosted in the GreenOps reporting repository. Review data sources, regional assumptions, and calculation methodology before using outputs in executive reporting.

Safe Usage Checklist

  • Treat emissions estimates as directional unless you have validated the calculation inputs against your billing/export pipeline.
  • Document reporting period and methodology when sharing results externally or with leadership.
  • Run in a non-production subscription/account/tenancy first and capture sample output before broader rollout.
  • Use least-privilege access. Current best hint from docs: Reader access to Azure consumption/resource data used by the reporting workflow.

Quick start (fast path)

Minimal steps to safely get value from this tool without reading the entire page first.

Estimated time: 15-20 minutes per subscriptionDifficulty: IntermediateAccess: Review / read-only
  1. 1. Confirm scope and permissions

    Use least privilege and test in a non-production scope first. Minimum access hint: Reader access to Azure consumption/resource data used by the reporting workflow.

  2. 2. Get the tool package / source

    View on GitHub and review the files before running.

    GitHub
  3. 3. Check prerequisites

    • ✅ PowerShell 5.1+ (Windows PowerShell or PowerShell Core)
    • ✅ Azure authentication: CLI, PowerShell module, or Service Principal
    • ✅ Carbon Optimization Reader role on target Azure subscriptions
  4. 4. Run safely and review output

    Source is hosted in the GreenOps reporting repository. Review data sources, regional assumptions, and calculation methodology before using outputs in executive reporting. Start with a small sample scope, then expand once results look correct.