A collection of Python scripts for automating Microsoft Azure infrastructure management, cost optimization, and administrative tasks.
This repository serves as a portfolio of cloud engineering tools designed to solve real-world operational challenges using the Azure SDK for Python.
| Script Name | Description | Key Services |
|---|---|---|
vm-auto-stop.py |
Automates cost savings by identifying and deallocating specific Virtual Machines by tags and resource group. | Compute, Tags |
VM-error-scanner.py |
Script automates the monitoring of Azure Virtual Machines to identify instances that are in a failed or error state. | Compute, Tags |
| (Coming Soon) | Future scripts for Storage Account management and Network security checks. | ... |
This script helps reduce cloud spend by automatically finding Virtual Machines that are meant for development (tagged Environment: Dev) and ensuring they are deallocated.
Key Logic:
- Authenticates securely using
DefaultAzureCredential. - Scans a target Resource Group for VMs.
- Filters for VMs with specific tags (e.g.,
Environment: Dev). - Checks the Instance View to see if the VM is currently
Running. - Action: Deallocates the VM to stop billing.
- Safety: Includes a
DRY_RUNflag to simulate actions without affecting production.
This script improves infrastructure observability by automatically scanning the subscription for Virtual Machines that have fallen into a "Failed" or unhealthy state, which might otherwise go unnoticed without manual portal checks.
Key Logic:
- Authenticates securely using
DefaultAzureCredential. - Iterates through all Virtual Machines in the subscription (or a specific Resource Group).
- Retrieves the Instance View for each VM to access real-time status codes.
- Filters the results to isolate VMs that are not in a healthy or successful state by two conditions.
- Reporting: specific details (VM Name, Resource Group, and Error Code) are printed to the console for immediate viewing.
To run these scripts, you will need:
- Python 3.8+
- Azure CLI (for local authentication)
- Azure Subscription (with permissions to manage resources)
python -m pip install azure-identity azure-mgmt-compute