Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
Learn how to delete all snapshots for a blob which could be IaaS VHDs
June 18, 2016
Q. How can I delete all snapshots for a blob?
A. To quickly delete all snapshots for a blob, for example a VHD, run the following PowerShell. Make sure you replace the file name, resource group and storage account variables.
$Container = 'vhds'$VHDName = 'DummyVM201656141318.vhd'$AzStorAccName = 'savtechsalrsscus'$AzResGroup = 'rg-scusa'$AzStrKey = Get-AzureRmStorageAccountKey -Name $AzStorAccName -ResourceGroupName $AzResGroup$AzStrCtx = New-AzureStorageContext $AzStorAccName -StorageAccountKey $AzStrKey[0].Value$VMsnaps = Get-AzureStorageBlob –Context $AzStrCtx -Container $Container | Where-Object {$_.ICloudBlob.IsSnapshot -and $_.Name -eq $VHDName -and $_.SnapshotTime -ne $null } foreach($VMSnap in $VMsnaps){ $VMSnap.ICloudBlob.Delete()}
You May Also Like