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 type | Best for | Typical consumer |
|---|---|---|
| ItemDetailsReport | Detailed carbon analysis and drill-down | FinOps / sustainability analysts |
| MonthlySummaryReport | Month-over-month trends | Leads and reporting dashboards |
| Overall Summary | High-level footprint overview | Executives / sustainability program owners |
| Top Items Monthly / Summary | Prioritizing highest emitters | Optimization teams |
Use summary reports for dashboards and item-level reports for remediation planning.
Standard collection workflow
- 1Start with a single subscription run to validate authentication and output formatting.
- 2Scale to `-AllSubscriptions` only after confirming performance expectations and role assignments.
- 3Use explicit `-StartDate`, `-EndDate`, and `-ReportType` for repeatable monthly reporting.
- 4Store CSV output in a stable folder for Power BI/Tableau ingestion and trend tracking.
.\\Get-AzureCarbonEmissions.ps1 -SubscriptionId "12345678-1234-1234-1234-123456789012".\\Get-AzureCarbonEmissions.ps1 -AllSubscriptions -GetFullDataset.\\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
| Mode | Best use case | Notes |
|---|---|---|
| Azure CLI / PowerShell context | Interactive testing and ad hoc runs | Fastest setup for validation |
| Service Principal | Scheduled reports / CI jobs | Use secure secret storage; avoid plain-text secrets in scripts |
| AllSubscriptions + full dataset | Periodic enterprise exports | Can take 15+ minutes in large estates |
CSV dashboard export
The script produces CSV output intended for sustainability dashboards and trend analysis.
| Output | Primary use | Downstream tool |
|---|---|---|
| Monthly summary CSV | Trend reporting | Power BI / Tableau |
| Item details CSV | Hotspot analysis | Analyst workflows / spreadsheets |
| Top emitters report | Prioritization | Optimization 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
Key Features
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.
Monthly Summary
Month-over-month carbon emissions trends and summaries for executive reporting.
Overall Summary
High-level carbon footprint overview across all subscriptions and time periods.
Top Items Monthly
Identify highest carbon-emitting resources and services by month for optimization targeting.
Top Items Summary
Overall ranking of highest carbon-emitting resources across the entire reporting period.
Custom Date Ranges
Flexible date range selection for any reporting period with automatic data availability validation.
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 -GetFullDatasetService 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.
Service Principal
Ideal for automation, scheduled tasks, and CI/CD pipelines. Provides non-interactive authentication.
Azure PowerShell
Fallback option using existing Azure PowerShell context. Great for PowerShell-heavy environments.
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 5Data 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.
Related CloudCostChefs Tools
Explore our complete suite of Azure optimization and sustainability tools
Mise-en-Tag Enforcer for Azure
Automated Azure resource tagging enforcement with governance policies and compliance reporting.
Mise-en-Place VM Scheduler
Multi-cloud VM scheduling automation for development environments and cost optimization.
Azure Cost Optimization Guide
Comprehensive guide to Azure cost optimization strategies, tools, and best practices.
What to do next
Pick the path that fits where you are right now.