How to get the Azure storage container blobs (Files) using PowerShell?

Microsoft TechnologiesSoftware & CodingPowerShell

To get blobs inside the Azure storage container using PowerShell, we will use the Get-AzStorageBlob command. . Before running this command, we need to make sure that the Azure cloud account is connected (Connect-AzAccount) and the proper subscription is set in which the storage account resides (Set-AzContext).

To work with the storage accounts we first need to set the Context for it and we will use the storage account key to set the context.

$rg = "az204"
$storageaccount = "az204storage05june"
$key = (Get-AzStorageAccountKey -ResourceGroupName $rg -
Name $storageaccount)[0].Value
$context = New-AzStorageContext -StorageAccountName $storageaccount -
StorageAccountKey $key

We have now created the Azure storage context. To get the Azure files (blobs) in the particular container, we will use the below command.

Get-AzStorageBlob -Container 'container1' -Context $context


This is how you can retrieve the Azure blobs from the storage container.

Published on 01-Sep-2021 07:59:31