CloudCostChefs: Monthly RG Cost Report Generator

Whip up chef-worthy HTML cost reports for every Azure RG in your subscription—no more portal puzzles, just PowerShell flavor.

Overview

Meet your new FinOps sous-chef: the Monthly RG Cost Report Generator. This PowerShell recipe whips up a sleek, chef-worthy HTML breakdown of every Resource Group’s spending in your Azure subscription—no enterprise fuss, just clear, digestible cost insights that help you plate up smarter cloud budgets.

Ideal for lean teams hungry for monthly cost snapshots without splurging on fancy tools—this PowerShell sous-chef automatically figures out last month’s dates, taps the Azure Cost Management API, and plates a full-course HTML report for every Resource Group (yes, even the zero-cost ones).

Download the Script

Ready to cook up your cost insights? Grab the Monthly RG Cost Report Generator script and start serving up clear Azure spending data today.

Download Script

Key Features

Automatic Date Detection

Automatically identifies the previous month's date range, making regular reporting simple.

Complete Coverage

Includes all Resource Groups in your subscription, even those with zero costs for comprehensive visibility.

Beautiful HTML Reports

Generates visually appealing HTML reports with CloudCostChefs styling for easy sharing and analysis.

Console Summary

Provides an immediate console summary for quick insights without opening the HTML report.

Perfect for Regular Reporting

Treat this tool as your monthly FinOps sous-chef—set it to run on the 1st of every month, and it will deliver a fresh batch of Azure spending insights to your team, no surprises, just consistent cost clarity.

Prerequisites

Before you fire up the Monthly RG Cost Report Generator, make sure your kitchen is stocked with these essentials:

  • PowerShell 5.1 or higher - The script is compatible with both Windows PowerShell and PowerShell Core
  • Az PowerShell Module - Required for Azure authentication and resource access
  • Azure Subscription - Active subscription with appropriate permissions
  • Appropriate Permissions - Reader access to the subscription and Cost Management Reader role

Installing Required Modules

If you don't have the Az module installed, you can install it with:

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

For the minimum required modules, you can use:

Install-Module -Name Az.Accounts -Scope CurrentUser -Repository PSGallery -Force
Permission Requirements

The script requires the following Azure RBAC roles:

  • Reader - To list all Resource Groups
  • Cost Management Reader - To access cost data via the Cost Management API

Installation

Setting up the Monthly RG Cost Report Generator is a piece of cake:

  1. Download the script - Save the Get-LastMonthRGCostReport.ps1 file to your preferred location
  2. Verify execution policy - Ensure your PowerShell execution policy allows running the script
  3. Install required modules - Make sure the Az.Accounts module is installed

Setting Execution Policy

If needed, you can set the execution policy to allow running the script:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Security Note

Always review scripts before running them, especially when changing execution policies. The Monthly RG Cost Report Generator is designed to be read-only and doesn't modify any Azure resources.

Usage

Basic Usage

The simplest way to use the script is to run it without parameters. This will:

  • Prompt you to select an Azure subscription (if you have access to multiple)
  • Generate a report for the previous month's costs
  • Save the report as "monthly-rg-costs.html" in the current directory
  • Open the report in your default browser
.\Get-LastMonthRGCostReport.ps1

Advanced Usage

The script supports several parameters for more customized usage:

ParameterDescriptionExample
-SubscriptionIdSpecify the Azure Subscription ID to target-SubscriptionId "abcdef12-3456-7890-abcd-ef1234567890"
-OutputPathCustom file path for the HTML report-OutputPath "C:\Reports\May2025.html"

Example Commands

Example 1: Target a specific subscription with default output path

.\Get-LastMonthRGCostReport.ps1 -SubscriptionId "abcdef12-3456-7890-abcd-ef1234567890"

Example 2: Use default subscription selection with custom output path

.\Get-LastMonthRGCostReport.ps1 -OutputPath "May2025_Azure_Costs.html"

Example 3: Specify both subscription and output path

.\Get-LastMonthRGCostReport.ps1 -SubscriptionId "abcdef12-3456-7890-abcd-ef1234567890" -OutputPath "Finance_May2025.html"
First-Time Usage

When running the script for the first time, you'll be prompted to authenticate with Azure if you're not already logged in. The script will store your authentication token for subsequent runs within the same PowerShell session.

Understanding the Report

The generated HTML report provides a comprehensive view of your Azure Resource Group costs for the previous month. Here's what you'll find in the report:

Header Section

  • CloudCostChefs branding
  • Report title with month and year
  • Subscription name
  • Date range covered by the report

Summary Box

  • Date range (inclusive start, exclusive end)
  • Total number of Resource Groups
  • Grand total cost in USD
  • Quick overview of your monthly spending

Cost Table

  • Resource Group names
  • Cost per Resource Group in USD
  • Sorted by cost (highest to lowest)
  • Total row at the bottom

Footer

  • Generation timestamp
  • Data source information
  • CloudCostChefs branding
  • Responsive design for all devices
Zero-Cost Resource Groups

The report includes all Resource Groups in your subscription, even those with zero costs. This provides a complete inventory of your resources and helps identify unused or newly created Resource Groups.

Customization Options

While the Monthly RG Cost Report Generator works great out of the box, you can customize it to better fit your needs. Here are some common customizations:

Modifying the Date Range

By default, the script generates a report for the previous month. To modify this behavior, you can edit the script and change the date calculation logic:

# Find this section in the script:
                   $now              = Get-Date
                   $startOfThisMonth = Get-Date -Year $now.Year -Month $now.Month -Day 1 -Hour 0 -Minute 0 -Second 0
                   $startOfLastMonth = $startOfThisMonth.AddMonths(-1)

                   # Modify for a different date range, for example, last 3 months:
                   $now              = Get-Date
                   $startOfThisMonth = Get-Date -Year $now.Year -Month $now.Month -Day 1 -Hour 0 -Minute 0 -Second 0
                   $startOfLastMonth = $startOfThisMonth.AddMonths(-3) # Changed from -1 to -3

Customizing the HTML Template

You can modify the HTML template to change the report's appearance or add additional information:

# Find the HTML template section (starts with $html = @")
                   # Modify the CSS styles or HTML structure as needed
                   # For example, to change the header color:

                   body {
                       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                       background-color: #f0f4f8; /* Change this to your preferred color */
                       color: #323130;
                       margin: 0;
                       padding: 40px;
                    }
Maintaining Script Functionality

When customizing the script, be careful not to modify the core functionality that retrieves and processes the cost data. Focus your changes on the date calculation logic, HTML template, or output formatting.

Automation

For regular reporting, you can automate the Monthly RG Cost Report Generator using various methods:

Windows Task Scheduler

Set up a scheduled task to run the script at the beginning of each month:

  1. Open Task Scheduler and create a new Basic Task
  2. Set it to run monthly on the 1st day
  3. Action: Start a program
  4. Program/script: powershell.exe
  5. Arguments: -ExecutionPolicy Bypass -File "C:\Path\To\Get-LastMonthRGCostReport.ps1" -OutputPath "C:\Reports\$(Get-Date -Format 'yyyy-MM')-costs.html"

Azure Automation

For a cloud-native approach, use Azure Automation:

  1. Create an Azure Automation account
  2. Import the Az.Accounts module
  3. Create a RunAs account or use Managed Identity
  4. Upload the script as a runbook (modify for automation context)
  5. Create a schedule to run monthly
  6. Configure output to save to Azure Storage or send via email
Authentication for Automated Runs

For automated runs, you'll need to modify the authentication method:

  • For Task Scheduler: Use saved credentials or certificate-based authentication
  • For Azure Automation: Use the RunAs account or Managed Identity

Troubleshooting

If you encounter issues with the Monthly RG Cost Report Generator, here are some common problems and solutions:

IssuePossible CauseSolution
Authentication ErrorSession expired or insufficient permissionsRun Connect-AzAccount manually first, or check your RBAC permissions
Empty Cost DataNew subscription or no resources deployedVerify the subscription has active resources, or try a different date range
API Request FailedNetwork issues or API throttlingCheck network connectivity, wait a few minutes and try again
Script Execution Policy ErrorRestrictive PowerShell execution policyRun Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Debugging Tips

For more detailed troubleshooting:

  • Check the Azure Activity Log for any API-related issues
  • Verify your Azure CLI or PowerShell Az module is up to date

Next Steps

After implementing the Monthly RG Cost Report Generator, consider these next steps to enhance your Azure cost management:

Implement Resource Tagging

Add tags to your Resource Groups for better cost allocation and reporting.

Learn about tagging strategies →

Set Up Budget Alerts

Configure Azure Budget Alerts to proactively monitor spending.

Explore budget alert setup →

Right-Size Your Resources

Identify and optimize over-provisioned resources to reduce costs.

Discover right-sizing techniques →

Implement Reserved Instances

Save on predictable workloads with Azure Reserved Instances.

Learn about Reserved Instances →
Building a FinOps Practice

The Monthly RG Cost Report Generator is just one tool in your FinOps toolkit. For a comprehensive approach to cloud financial management, explore our complete FinOps implementation guide.

Was this documentation helpful?

Have suggestions for improving this document? Contact us.