Remove-AzStorageContainer

In this Azure PowerShell article, we will discuss the syntax and usage of the Remove-AzStorageContainer PowerShell command with examples.

You can use the Get-AzStorageContainer PowerShell command to retrieve the storage container from a specified storage account.

Remove-AzStorageContainer

The Remove-AzStorageContainer is a very good Azure PowerShell command that can help you to remove the storage container that you have specified with this command.

Syntax

Below is the syntax of the Remove-AzStorageContainer PowerShell command.

Remove-AzStorageContainer
 [-Name] <String>

Let’s see an example of how to use the Remove-AzStorageContainer PowerShell command.

Example:

You can execute the below PowerShell command that can help you to delete the storage container named “azure-webjobs-hosts” that belongs to the storage account “demorg2913f”.

$mynewsARG = "DEMORG2"
$mynewsAName = "demorg2913f"
$mynewsAKey = (Get-AzStorageAccountKey -ResourceGroupName $mynewsARG -AccountName $mynewsAName).Value[0]
$myuctx = New-AzStorageContext -StorageAccountName $mynewsAName -StorageAccountKey $mynewsAKey
Remove-AzStorageContainer -Name "azure-webjobs-hosts" -Context $myuctx

After executing the above PowerShell script, It prompted me to confirm the deletion process so just clicked on the Yes button and then I can able to delete the storage container successfully without any issues. You can check out the below screenshot for your reference.

Remove-AzStorageContainer PowerShell

Just to make sure, I reran the script and this time I got the output “Remove-AzStorageContainer : Can not find the container ‘azure-webjobs-hosts’.” which means the storage container has been deleted successfully.

Remove-AzStorageContainer

Conclusion

In this Azure PowerShell article, we discussed the syntax and usage of the Remove-AzStorageContainer command with examples. Thanks for reading this quick article !!!