How to list Azure Storage Containers and Blobs
With the new Az
module, you need to do the following
Import-Module Az
$azStorageAccountName = "" # Name of your storage account
$azStorageAccountKey = "" # Access key for your storage account
$azContainerName = "" # Container name to list your blobs
$azResourceGroupName = "" # Resource group name where storage account lives
$connectionContext = (Get-AzStorageAccount -ResourceGroupName $azResourceGroupName -AccountName $azStorageAccountName).Context
# Get a list of containers in a storage account
Get-AzStorageContainer -Name $azContainerName -Context $connectionContext | Select Name
# Get a list of blobs in a container
Get-AzStorageBlob -Container $azContainerName -Context $connectionContext | Select Name
Not sure if this is what you want, but I am able to list containers using New-AzureStorageContext
and Get-AzureStorageContainers
.
$ctx = New-AzureStorageContext -StorageAccountName <name> -StorageAccountKey <key>
Get-AzureStorageContainer -Context $ctx