Analyze Azure resource costs and get actionable optimization recommendations with projected savings.
Project description
Azure Cost Optimizer
A powerful CLI tool that analyzes Azure resources and identifies cost optimization opportunities. Provides actionable recommendations with projected savings across compute, storage, networking, and database services.
Features
- 30 cost checks across 5 categories (Compute, Storage, Networking, Database, General)
- Severity classification — HIGH, MEDIUM, LOW with effort estimates
- Beautiful terminal output — Rich tables, panels, color-coded findings
- Export reports — JSON and CSV formats for stakeholder sharing
- Demo mode — Try instantly without Azure credentials
- Filtering — By severity level or resource category
- Optimization grading — Letter grade (A-F) based on savings potential
Quick Start
Install
pip install -e .
Run Demo
azure-cost scan --demo
See All Checks
azure-cost summary
Usage
Scan with Demo Data
# Full scan with demo data
azure-cost scan --demo
# Filter by severity
azure-cost scan --demo --severity HIGH
# Filter by category
azure-cost scan --demo --category COMPUTE
# Export JSON report
azure-cost scan --demo --export-json report.json
# Export CSV report
azure-cost scan --demo --export-csv findings.csv
# Combine filters and export
azure-cost scan --demo --severity HIGH --category DATABASE --export-json critical-db.json
Available Commands
| Command | Description |
|---|---|
azure-cost scan --demo |
Run cost analysis with demo data |
azure-cost summary |
Show all 30 checks the tool performs |
azure-cost --version |
Show version |
What It Checks
Compute (7 checks)
| Check | Severity | Potential Savings |
|---|---|---|
| Stopped but allocated VMs | HIGH | ~85% |
| Idle VMs (< 5% CPU) | HIGH | ~95% |
| Underutilized VMs (< 20% CPU) | MEDIUM | ~40% |
| Dev/test VMs without auto-shutdown | MEDIUM | ~65% |
| Reserved Instance candidates | LOW | ~38% |
| Scale sets with fixed instance count | MEDIUM | ~30% |
| Overprovisioned App Services | HIGH | ~60% |
Storage (5 checks)
| Check | Severity | Potential Savings |
|---|---|---|
| Unattached managed disks | HIGH | 100% |
| Premium disks with low IOPS | MEDIUM | ~65% |
| Old snapshots (> 90 days) | MEDIUM | 100% |
| Aging snapshots (> 30 days) | LOW | ~80% |
| Hot storage with infrequent access | MEDIUM | ~45% |
Networking (5 checks)
| Check | Severity | Potential Savings |
|---|---|---|
| Orphaned public IP addresses | HIGH | 100% |
| Load balancers with no backends | HIGH | 100% |
| Load balancers with no rules | MEDIUM | ~50% |
| Unused NAT Gateways | HIGH | 100% |
| Oversized Application Gateways | MEDIUM | ~35% |
Database (8 checks)
| Check | Severity | Potential Savings |
|---|---|---|
| Oversized SQL Databases (low DTU) | HIGH | ~55% |
| SQL storage over-provisioned | LOW | ~10% |
| Dev/test DBs on production SKUs | HIGH | ~80% |
| Idle Cosmos DB accounts | HIGH | ~90% |
| Over-provisioned Cosmos DB RUs | MEDIUM | ~45% |
| Oversized Redis Cache | MEDIUM | ~50% |
| Idle Redis Cache | HIGH | ~95% |
| Underutilized MySQL servers | MEDIUM | ~45% |
General (5 checks)
| Check | Severity | Potential Savings |
|---|---|---|
| Empty resource groups | LOW | — |
| High-cost untagged resources | MEDIUM | — |
| Untagged resources | LOW | — |
| Resources in expensive regions | LOW | ~20% |
| Long-running resources (> 1 year) | LOW | — |
Architecture
azure_cost_optimizer/
├── cli.py # Click CLI entry point
├── scanner.py # Orchestrator — runs all analyzers
├── models.py # Data models (Severity, Category, CostFinding, etc.)
├── demo.py # Demo mode with realistic mock data
├── analyzers/
│ ├── base.py # Abstract base analyzer
│ ├── compute.py # VM, scale set, app service checks
│ ├── storage.py # Disk, snapshot, storage account checks
│ ├── networking.py # Public IP, load balancer, NAT gateway checks
│ ├── database.py # SQL, Cosmos DB, Redis, MySQL checks
│ └── misc.py # Resource groups, tags, regions
└── output/
├── console.py # Rich terminal rendering
└── report.py # JSON/CSV export
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest -v
# Run linter
ruff check .
# Run with demo
azure-cost scan --demo
Tech Stack
- Python 3.9+ — Core runtime
- Click — CLI framework
- Rich — Terminal formatting and tables
- pytest — Testing framework
- ruff — Linting
License
MIT License — see LICENSE for details.
Author
Sanjay S — Senior DevOps Engineer
- GitHub: @SanjaySundarMurthy
- Portfolio: sanjaysundarmurthy-portfolio.vercel.app
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_cost_optimizer-1.0.0.tar.gz.
File metadata
- Download URL: azure_cost_optimizer-1.0.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e7ee6afebdfdaaafc508e3165fe4c02b660d8399b612320201a02fc9544644c
|
|
| MD5 |
6a3e96e8d41f1895cfe002de873ea224
|
|
| BLAKE2b-256 |
9b5b3578e5d38881dc17936b6f56239eeb7dbdd868d6a26faf2d68823cef84c3
|
File details
Details for the file azure_cost_optimizer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: azure_cost_optimizer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42c60a03c0e06f83a02e464ab0322fc3a4254ef629adfc74c13f93b68c00e1f1
|
|
| MD5 |
53d2df42e2755b5ed009eef1ae8edf65
|
|
| BLAKE2b-256 |
7a4ffee1a579da77488a03733f2a75d7f307411ddf789b75cf13684689248e1a
|