Skip to content

πŸ” Script to inventory Azure SQL Databases across all servers and resource groups, using Azure CLI. Displays service tier, status, and zone redundancy in a readable table format.

License

Notifications You must be signed in to change notification settings

Azure/azure-sql-db-inventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Azure SQL Database Inventory Script

This powershell script leverages the Azure CLI to inventory all Azure SQL Databases in your subscription. It organizes the databases by SQL server and resource group, and displays useful details such as service tier, current status, and zone redundancy.

Ideal for cloud administrators, DevOps engineers, or developers managing large-scale Azure environments.


πŸ“‹ Features

  • βœ… Lists all Azure SQL Databases and Azure SQL Managed Instances across your subscription
  • πŸ”’ Displays the total number of subscriptions scanned
  • πŸ”  Automatically sorts subscriptions alphabetically for consistent output
  • πŸ—‚οΈ Groups databases by their parent SQL server and resource group
  • πŸ“Š Displays database service tier, status, redundancy type, storage size, failover groups (applicable only to Azure SQL Databases) and compute details in a clean table format
  • πŸ” Uses standard CLI tools
  • 🧩 Easily customizable for filtering, CSV export

πŸ“¦ Pre-requisites

To use this script, you'll need the following installed:

  • Git
    Install instructions

  • Azure CLI
    Install instructions

  • Login to your Azure account before running the script:

    az login
    
  • βœ… Minimum Role Required To run your script successfully, a user needs at least the Reader role at the subscription level plus visibility into the SQL resources.

    Specifically, they need permission to:

    • List Azure resources (for az resource list)
    • List SQL servers and databases (for az sql db list)

πŸš€ Getting Started

πŸ”§ 1. Clone the repository

git clone https://github.com/Azure/azure-sql-db-inventory.git

▢️ 2. Run the script

cd azure-sql-db-inventory
cd scripts
az login
.\list-azure-sql-databases.ps1

image

πŸ–₯️ Example Output

image


πŸ”— References


πŸ› οΈ Troubleshooting

If you encounter any issues, here are some common solutions:

  1. Error: "Unable to authenticate"

    • Ensure you've run az login and that you have the necessary permissions for the subscription.
  2. Error: "Command not found"

    • Make sure you've installed the Azure CLI and are running the script in the correct environment (Bash or PowerShell).
  3. Output not as expected

    • Ensure your subscription contains SQL databases and that the az sql db list command is functioning properly.

For more help, refer to the Azure CLI troubleshooting guide.

About

πŸ” Script to inventory Azure SQL Databases across all servers and resource groups, using Azure CLI. Displays service tier, status, and zone redundancy in a readable table format.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •