Skip to content

Instantly share code, notes, and snippets.

@bcnzer
Created December 18, 2017 09:28
Show Gist options
  • Save bcnzer/b7f35ef04f1ab22bbc7e99c57c939072 to your computer and use it in GitHub Desktop.
Save bcnzer/b7f35ef04f1ab22bbc7e99c57c939072 to your computer and use it in GitHub Desktop.
Deleted all content from an Azure Storage blob container
# You will either need variables created for WolfTrackerBlobKey or just put the text there in quotes. Ditto with BlobServiceName and
# WolfTrackerBlobContainer. I would suggest you store WolfTrackerBlobKey in Azure Key Vault and pull it from there
$Context = New-AzureStorageContext -StorageAccountName $(BlobServiceName) -StorageAccountKey $(WolfTrackerBlobKey)
$blobs = Get-AzureStorageBlob -Context $Context -Container $(WolfTrackerBlobContainer)
foreach ($blob in $blobs)
{
Write-Host ("Removing Blob: {0}" -f $blob.Name)
Remove-AzureStorageBlob -ICloudBlob $blob.ICloudBlob -Context $Context
}
Write-Host "DONE - deleted all the files in the container $ContainerName"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment