Vijai Anand Ramalingam

Jan 25, 20191 min

How to get all the containers from specific Azure Storage Account using PowerShell

Updated: Mar 14, 2023

In this article, you will see how to get all the containers from specific Azure Storage Account using PowerShell.

Install the Azure PowerShell Module:

Open Windows PowerShell window and run the below command.

Install-Module -Name Az –AllowClobber

Get all the containers:

Open a text file. Copy and paste the below script. Save the file as script.ps1.

################# Azure Blob Storage - PowerShell ####################

## Input Parameters

$resourceGroupName="psspschennairg"

$storageAccName="psspschennaistorageacc"

## Connect to Azure Account

Connect-AzAccount

## Function to get all the containers

Function GetAllStorageContainer

{

Write-Host -ForegroundColor Green "Retrieving storage container.."

## Get the storage account from which container has to be retrieved

$storageAcc=Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName

## Get the storage account context

$ctx=$storageAcc.Context

## List all the containers

Get-AzStorageContainer -Context $ctx

}

GetAllStorageContainer

## Disconnect from Azure Account

Disconnect-AzAccount

######################################################################

Open Windows PowerShell window and navigate to the location where the script file was saved.

Run the following command.

.\script.ps1

Summary:

Thus in this article you saw how to get all the containers from specific Azure Storage Account using PowerShell.

    0