How to get filenames from Azure blob storage using PowerShell? | List filenames from Azure Storage

This article guides

How to get filenames from Azure blob storage using PowerShell?

What is Blob storage?

Blob storage or Azure storage is file storage service on Microsoft Azure cloud. We can use this to store various types of file. It supports Blob, file and table. Most common use of azure storage to store file as blob in container. You can access those files form Azure portal or Azure Storage explorer.

To connect Azure storage , you can use either storage account name and access key. You can also create shared access signature to access specific container from storage. It also allows to set expiry of shared access token which can allow to maintain security and integrity of data.

How to connect Azure Storage using Power Shell?

To connect Azure storage using Power Shell, you need to first connect with Azure Subscription on which this storage account hosted. Also you need to install PowerShell modules and command for azure storage.

To connect Azure Subscription, You need to run

Connet-AzAccount

If you have multiple subscription then you need to get specific tenant id and subscription name of that subscription and pass the parameter like

Connect-AzAccount -TenantID TenantID -SubscriptionName Subscription Name

To get tenant ID , you can got Azure portal and search for Active directory, click on active directory and you will find tenant ID.

Once you connect to respective subscription now you need to connect azure storage account to get all filenames from container. Below script can help. Below script can help to list all files present on Azure storage container.

How to get filenames from Azure blob storage using PowerShell? or List filenames from Azure Storage

$RGname = "Resource group name"
$storageaccountName = "storage account name"
$ctx = New-AzStorageContext -StorageAccountName $storageaccountName -UseConnectedAccount
Get-AzStorageBlob -Context $ctx -Container "landing" | select name

Resource group name and storage account name can be found on azure portal. You need to search storage account and in that you will find resource group name as well.

Leave a Comment