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.
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.
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 -GetFullDataset
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.
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 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.
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.