Azure: Delete all *test.zip blobs from Azure Storage using Powershell

azure, azure-storage, powershell

Solution

Since blob storage only support individual blob deletes at this moment (i.e. it doesn't support batch deletes), your only option would be to read individual blobs from the output file and delete the blob one by one.

Based on your comments below, try the following:

$context = New-AzureStorageContext -StorageAccountName "account name" -StorageAccountKey "account key"

Get-AzureStorageBlob -Container "containername" -blob *test.zip -Context $context | Remove-AzureStorageBlob

The script above will first list matching blobs and then delete them one by one.

Problem

I would like to delete all files from an azure storage container where the filename includes test.zip I am able to get all the files and export them to a file like this: ``` $context = New-AzureStorageContext -StorageAccountName ACCOUNTNAME ` -StorageAccountKey ACCOUNTKEY get-azurestorageblob -Container CONTAINERNAME ` -blob *test.zip ` -Context $context | Out-File c:\files\f.txt ` -width 500 ``` What is the simplest way to delete all the results using the `remove-azurestorageblob` command?

Original source