title | description | services | documentationcenter | author | manager | editor | ms.assetid | ms.custom | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Azure PowerShell Script Sample - Delete containers by prefix | Microsoft Docs |
Delete Azure Storage blob containers based on a container name prefix. |
storage |
na |
tamram |
timlt |
tysonn |
mvc |
storage |
storage |
na |
azurecli |
sample |
06/13/2017 |
tamram |
This script deletes containers in Azure Blob storage based on a prefix in the container name.
[!INCLUDE sample-powershell-install]
[!INCLUDE quickstarts-free-trial-note]
[!code-powershellmain]
Run the following command to remove the resource group, remaining containers, and all related resources.
Remove-AzureRmResourceGroup -Name containerdeletetestrg
This script uses the following commands to delete containers based on container name prefix. Each item in the table links to command-specific documentation.
Command | Notes |
---|---|
Get-AzureRmStorageAccount | Gets a specified Storage account or all of the Storage accounts in a resource group or the subscription. |
Get-AzureStorageContainer | Lists the storage containers associated with a storage account. |
Remove-AzureStorageContainer | Removes the specified storage container. |
For more information on the Azure PowerShell module, see Azure PowerShell documentation.
Additional storage PowerShell script samples can be found in PowerShell samples for Azure Blob storage.