Skip to content

This repository contains a Python script that automates Azure cost reporting by fetching cost usage data from the Azure Management API and sending a daily cost report via email.

Notifications You must be signed in to change notification settings

snhaider9977/AZURES-COST-PYTHON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Automating Azure Cost Reporting with Python

This repository contains a Python script that automates Azure cost reporting by fetching cost usage data from the Azure Management API and sending a daily cost report via email.

Table of Contents

  1. Prerequisites
  2. Installation
  3. Usage
  4. Configuration

Prerequisites

Before running the script, ensure you have the following prerequisites:

  1. Python 3.x installed on your system.
  2. An Azure subscription with the necessary permissions to access the Cost Management API.
  3. Azure AD credentials: subscription_id, tenant_id, client_id, and client_secret.

Installation

  1. Clone this repository to your local machine using git clone.
  2. Navigate to the repository's directory.

Usage

  1. Open the Python script azure_cost_report.py in a text editor.
  2. Replace the placeholder values for subscription_id, tenant_id, client_id, and client_secret with your Azure AD credentials.
    subscription_id = 'YOUR_SUBSCRIPTION_ID'
    tenant_id = 'YOUR_TENANT_ID'
    client_id = 'YOUR_CLIENT_ID'
    client_secret = 'YOUR_CLIENT_SECRET'
  3. Modify the email_recipients variable with the email addresses of the recipients you want to send the cost report to.

    python

    email_recipients = ['recipient1@example.com', 'recipient2@example.com']

  4. Run the script using python azure_cost_report.py.
  5. The script will fetch the cost data and send the cost report via email to the specified recipients.

Configuration

The script allows you to configure the following parameters:

  • subscription_id: Your Azure subscription ID.
  • tenant_id: Your Azure AD tenant ID.
  • client_id: Your Azure AD application/client ID.
  • client_secret: Your Azure AD application/client secret.
  • monthly_budget: The monthly budget amount in your local currency (e.g., INR).
  • email_sender: The email address from which the cost report will be sent.
  • email_password: The password for the email sender account.
  • email_smtp_server: The SMTP server address for the sender email account.
  • email_smtp_port: The SMTP port number for the sender email account.
  • email_recipients: A list of email addresses to which the cost report will be sent.

OUTPUT

Image

About

This repository contains a Python script that automates Azure cost reporting by fetching cost usage data from the Azure Management API and sending a daily cost report via email.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages