Azure Cost Tracker is a Python-based tool that tracks Azure subscription costs, generates dynamic HTML reports, and sends notifications via email or webhooks (Microsoft Teams, Slack, etc.).
✅ Fetches daily, monthly and yearly forecast cost reports for Azure subscriptions.
✅ Dynamically groups data by cost categories for better readability.
✅ Sends notifications via email and webhook (Microsoft Teams, Slack, etc.).
✅ Allows previewing email reports.
✅ Modern, Clean HTML report.
✅ Follows best-practice Python project structure.
azure-cost-tracker/
│── src/
│ ├── main.py # Main script
│ ├── config.py # Configurations (subscriptions, billing periods)
│ ├── services/
│ │ ├── azure_auth.py # Fetch and Manages Access Token
│ │ ├── azure_billing.py # Fetch Azure subscription's billing details
│ │ ├── azure_cost.py # Fetch Azure cost data
│ │ ├── email_service.py # Sends email notification
│ │ ├── html_renderer.py # Render HTML reports
│ │ ├── webhook_service.py # Sends webhook notifications
│ ├── utils/
│ │ ├── logger.py # Logging setup
│ │ ├── utils.py # Helper functions
│── templates/
│ ├── email_template.html # Email template
│── static/
│ ├── images/
│ │ ├── logo.svg # Default logo (replaceable)
│ │ ├── report_screenshot.png # HTML report preview
│── .env # Environment variables
│── README.md # Project documentation
│── requirements.txt # Dependencies
│── setup.py # Package setup
git clone https://github.com/interittus13/AzureCostTracker
cd azurecosttracker
pip install -r requirements.txt
Create a .env
file with your settings:
TENANT_ID=your-azure-tenant-id
CLIENT_ID=your-azure-client-id
CLIENT_SECRET=your-azure-client-secret
SUBSCRIPTION_IDS=subscription-id1,subscription-id2
EMAIL_FROM=your-email@example.com
EMAIL_TO=test@example.com,test2@yopmail.com
SMTP_SERVER=smtp.office365.com
SMTP_PORT=587
SMTP_PASS=your-password
WEBHOOK_URL=https://your-teams-webhook-url
NOTIFY_METHOD=email # Options: email, webhook, both
python -m src.main
azure-cost-tracker
- Sends a formatted HTML report via Outlook.
- Supports multiple recipients (comma-separated in
.env
). - Email preview before sending.
- Sends a summary message via webhook.
- Supports Teams, Slack, and custom webhooks.
- Uses
WEBHOOK_URL
from.env
.
- Sends both email and webhook notifications when
NOTIFY_METHOD=both
.
1️⃣ Go to Microsoft Teams → Your Channel → Click ...
→ Connectors
.
2️⃣ Search for "Incoming Webhook" → Click Add
.
3️⃣ Name the webhook (e.g., Azure Cost Alerts
).
4️⃣ Copy the generated Webhook URL.
5️⃣ Add it to .env
:
WEBHOOK_URL=https://your-teams-webhook-url
This project is open-source under the MIT License.