This Azure PowerShell article will discuss the syntax and usage of the Get-AzStorageContainer PowerShell cmdlet, along with a few examples.
Get-AzStorageContainer
The Get-AzStorageContainer is an excellent Azure PowerShell cmdlet that can help you list Azure Storage Containers.
Syntax
Below is the syntax of the Get-AzStorageContainer PowerShell command.
Get-AzStorageContainerGet-AzStorageContainer
[[-Name] <String>]Examples
Let’s discuss a few get-azstoragecontainer examples.
Example-1:
You can run the PowerShell command below to retrieve the Azure storage container lists.
Get-AzStorageContainerBut, after executing the above command, I got the following error.
“Get-AzStorageContainer : Could not get the storage context. Please pass in a storage
context or set the current storage context.”
You can see the same error below

To resolve the error “Get-AzStorageContainer: Could not get the storage context,” I needed to pass the storage context as an argument to the Get-AzStorageContainer command. So, I ran the complete PowerShell script below.
$mysARG = "DEMORG2"
$mysAName = "demorg2913f"
$mysAKey = (Get-AzStorageAccountKey -ResourceGroupName $mysARG -AccountName $mysAName).Value[0]
$mystrgctx = New-AzStorageContext -StorageAccountName $mysAName -StorageAccountKey $mysAKey
Get-AzStorageContainer -Context $mystrgctxAfter executing the above script, I got the expected output as below.
Storage Account Name: demorg2913f
Name PublicAccess LastModified IsDeleted Ve
rs
io
nI
d
---- ------------ ------------ --------- --
azure-webjobs-hosts Off 1/19/2023 7:14:38 AM +00:00
azure-webjobs-sec... Off 1/19/2023 7:14:44 AM +00:00 You can check out the same output as below

Example-2:
You can also execute the PowerShell command below to retrieve the list of containers whose names start with “azure-webjobs”.
$mysARG = "DEMORG2"
$mysAName = "demorg2913f"
$mysAKey = (Get-AzStorageAccountKey -ResourceGroupName $mysARG -AccountName $mysAName).Value[0]
$mystrgctx = New-AzStorageContext -StorageAccountName $mysAName -StorageAccountKey $mysAKey
Get-AzStorageContainer -Name azure-webjobs* -Context $mystrgctxAfter executing the above script, I got the expected output as below

Example-3:
The below script, along with the storage context, will get you the storage container named “azure-web jobs-hosts.”
Get-AzStorageContainer -Name "azure-webjobs-hosts" -Context $mystrgctxAfter executing the above script, I got the below-expected output
Storage Account Name: demorg2913f
Name PublicAccess LastModified IsDeleted Ve
rs
io
nI
d
---- ------------ ------------ --------- --
azure-webjobs-hosts Off 1/19/2023 7:14:38 AM +00:00 You can see the same output below

Video Tutorial
You can use the Remove-AzStorageContainer PowerShell command to delete an unused storage container.
Wrapping Up
In this article, we discuss the syntax and usage of the Get-AzStorageContainer PowerShell command, providing examples. Thanks for reading these examples !!!