Reputation: 351
I am writing a powershell script to delete blobs inside my storage account. I have a container named test and inside test I have multiple folders like "Group1", "Group2" etc upto "GroupN". And each of these folders have 1000s of blobs inside them. My goal is to write a powershell script that can delete the folder in the easiest way.
I was able to fetch the blob references but that made me iterate through the references and delete the blob individually instead of deleting the entire folder. Below is the script I have written.
$existingStorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -AccountName $storageAccountName
$existingContainer = Get-AzureStorageContainer -Context $existingStorageAccount.Context -Name $containerName
$existingBlob = Get-AzureStorageBlob -Context $existingStorageAccount.Context -Container $containerName -Prefix "Group1"
At this point I have the list of blobs inside the folder but then I have to loop through them which will perform poorly when I have 1000s of blobs inside the folder.
Is there a simpler way to delete the folder "Group1"?
Upvotes: 1
Views: 610
Reputation: 2405
I have found this StackOverflow thread in which "Mahesh Jasti" explained that the folders aren't actually real:
It is all logical representation of folder structure and you can ignore the folders under any container
I believe looping would be your only option :)
Upvotes: 2