top of page
Writer's pictureVijai Anand Ramalingam

How to get all the blobs from Azure Storage Account using PowerShell

Updated: Mar 14, 2023

In this article, you will see how to get all the blobs from 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 blobs:

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 blobs

Function GetAllBlobs

{

Write-Host -ForegroundColor Green "Retrieving all blobs from storage container.."

## Get the storage account

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

## Get the storage account context

$ctx=$storageAcc.Context

## Get all the containers

$containers=Get-AzStorageContainer -Context $ctx

## Loop through the containers

foreach($container in $containers)

{

## Get all the blobs

Get-AzStorageBlob -Container $container.Name -Context $ctx

}

}

GetAllBlobs


## 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 blobs from Azure Storage Account using PowerShell.

0 comments

Comments


bottom of page