Mastering Azure Costs: Building Automated Weekly Reports with PowerShell

Introduction

If you’ve ever tried to automate Azure cost reporting using Invoke-AzCostManagementQuery, you know it’s not straightforward. The cmdlet’s complexity and sparse documentation can make what seems like a simple task into a challenging endeavor. After spending considerable time decoding its quirks and experimenting with various approaches, I’ve developed a PowerShell-based solution for automated weekly cost reporting.

The Current Solution

This standalone PowerShell script generates comprehensive HTML reports every Monday morning, comparing service costs between weeks. It’s designed to help teams track and understand their Azure spending patterns with minimal setup overhead.

Requirements

  • Azure subscription with Cost Management Reader right
  • PowerShell Modules
    • Az.CostManagement
    • Az.Accounts (Minimum 4.0.1 version)
  • Three subscription tags configured (Optional):
    • Environment
    • CostCenter
    • Owner

Why Weekly Reports?

The script runs on Mondays, analyzing the previous completed week versus the week before that. This approach ensures we’re always comparing full weeks of data (Monday-Sunday), making trends and anomalies easier to spot.

What You Get

  • Week-over-week service cost comparisons
  • Daily cost breakdowns
  • Visual indicators for cost changes
  • Clean HTML output

Azure Costs Management

Looking Forward

This is just the beginning. Future versions will integrate with Azure Automation for improved scheduling and management capabilities. The plan is to enhance the solution with:

  • Budget tracking and alerts
  • Multi-subscription support
  • Email notifications via Azure Communication Services
  • Extended cost analytics

Download (Premium Members Only)

Leave a Comment

Contact me

If you’re interested in learning about Mastering Azure Costs: Building Automated Weekly Reports with PowerShell. I can help you understand how this solution can benefit your organization and provide a customized solution tailored to your specific needs.

Table of Contents