Created
December 18, 2017 09:28
-
-
Save bcnzer/b7f35ef04f1ab22bbc7e99c57c939072 to your computer and use it in GitHub Desktop.
Deleted all content from an Azure Storage blob container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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