How to List All Storage Accounts in an Azure Subscription Using Azure CLI

In this blog post, we will go through the steps required to list all storage accounts in an Azure subscription using Azure CLI.

Azure Command-Line Interface (CLI) is a powerful tool that enables developers and administrators to manage their Azure resources. One of the essential tasks in managing your Azure infrastructure is to keep track of your storage accounts.

To start, open your terminal or command prompt and login into your Azure account using the following command:

az login

This command will open a web page where you can enter your Azure credentials. Once you’ve successfully logged in, the terminal will display information about your subscriptions.

If you have multiple subscriptions, you’ll need to set the active one you want to work with using the following command:

az account set --subscription "Your Subscription ID

Replace “Your Subscription ID” with the actual subscription ID you want to use. You can find this ID in the output of the az login command.

List all storage accounts

To list all storage accounts in your subscription, run:

az storage account list --query '[].{Name:name, ResourceGroupName:resourceGroup}' --output table

Filter the storage accounts list

You can filter the list of storage accounts based on specific criteria. For example, to display storage accounts located in a specific region, use the following command:

az storage account list --query "[?location=='eastus']" --output table

Replace “eastus” with the desired Azure region. This command will display a table containing only the storage accounts in the specified region.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.