A powerful bash script for tracking and reporting Azure cloud resources with automated output generation.
The Azure Resource Tracker is a comprehensive monitoring tool that generates detailed reports of your Azure cloud infrastructure. It provides insights into virtual machines, storage accounts, Azure functions, and user accounts in a structured format.
- Multi-Resource Monitoring: Tracks VMs, Storage Accounts, Functions, and Users
- Automated Reporting: Generates timestamped reports in the
outputs/directory - Auto-Directory Creation: Automatically creates output directory if it doesn't exist
- JSON Formatted Output: Clean, parseable user data using
jq - Error Handling: Built-in error detection and pipeline failure protection
- Debug Mode: Comprehensive logging for troubleshooting
Before running this script, ensure you have:
-
Azure CLI installed and configured
# Install Azure CLI (Ubuntu/Debian) curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Login to Azure az login
-
jq for JSON processing
# Install jq (Ubuntu/Debian) sudo apt-get install jq -
Proper Azure Permissions
- Reader access to subscription resources
- User.Read.All permission for Azure AD user listing
az_resource_tracker_project/
├── az_resource_tracker.sh # Main script file
├── README.md # Documentation
└── outputs/ # Report output directory
└── outputof_resourcetracker # Generated reports
Make the script executable and run:
chmod +x az_resource_tracker.sh
./az_resource_tracker.shAdd to crontab for automated daily reports:
# Edit crontab
crontab -e
# Add entry for daily execution at 8 AM
0 8 * * * /path/to/az_resource_tracker.shThe script generates comprehensive reports including:
- Account names and resource groups
- Performance tiers and replication settings
- Access configurations
- VM names, sizes, and locations
- Power states and OS information
- Network configurations
- Function app names and resource groups
- Runtime versions and hosting plans
- Configuration settings
- User IDs and display names
- Email addresses (User Principal Names)
- Clean JSON formatting
Set these environment variables for customization:
# Custom output directory
export OUTPUT_DIR="./custom_reports"
# Custom output filename
export OUTPUT_FILENAME="azure_resources_$(date +%Y%m%d)"The script includes several configurable options:
- Debug Mode:
set -xfor verbose output - Error Handling:
set -efor immediate exit on errors - Pipeline Failure Protection:
set -o pipefail
-
Azure CLI Not Authenticated
az login --use-device-code
-
Permission Denied Errors
chmod +x az_resource_tracker.sh
-
jq Command Not Found
sudo apt-get update && sudo apt-get install jq
The script runs in debug mode by default. To disable:
# Comment out the debug line
# set -xReports are generated with timestamps and include:
Azure Resource Report - Sun Aug 10 10:30:45 UTC 2025
=================
[Storage Account Details...]
[VM Details...]
[Function App Details...]
[User Details in JSON format...]
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
- v1.0 (August 2025) - Initial release
- Basic Azure resource tracking
- Multi-resource support
- Automated report generation
Amitabha
- Creation Date: August 9, 2025
- Version: v1
This project is licensed under the MIT License - see the LICENSE file for details.
- Azure CLI team for excellent tooling
- jq developers for JSON processing capabilities
- Open source community for continuous inspiration
For questions or support, please open an issue in the repository.