0

I have some virtual machines in the Azure cloud, and I've just found that there are several .vhd files (all 127GB) on one of my premium storage accounts. I don't ever recall creating these by snap-shotting my machines, so I'm wondering why there are multiple files with different dates on. Can old ones just be deleted safely, and also, how can I stop these from being created autmatically, if indeed they are being automatically created? Azure premium storage is a little pricey, so I'm keen to try and understand what is going on here and cut down on the storage spending where necessary.

5lovak
  • 442
  • 5
  • 11

2 Answers2

2

It's not created automatically. Theses are probably leftovers from previously created Virtual Machines that does not exist anymore. When you delete a VM, it's vhd remains in the storage. You can safely delete these disks if they are not in use and you know it's not from any previous VM you want to recover. Disks in use (attached to VMs) are not allowed to be deleted.

Bruno Faria
  • 3,814
  • 1
  • 13
  • 18
  • Thanks for your reply Bruno, but two things - I haven't deleted the VM's (although they are stopped and I likely don't need them anymore), and also, why are there 3 .vhd files for one of my VM's? Like I say I haven't created any snap shots, and these 127 GB files on premium storage will be costing me money. I would like to know how and when they get created so I know what I'm looking at when I create VM' in the future. – 5lovak Mar 14 '17 at 09:03
  • additional disks? They are created when you create a VM, but just the OS disk, except if you are using marketplace templates which could spam additional data disks. There's no such thing like disks appearing on your storage without your consent. Check activity log to see what, who and when compute resources were created. – Bruno Faria Mar 14 '17 at 12:32
0

Agree with Bruno, by the way, we can use PowerShell to list the VHD and VHD's status:

Login-AzureRmAccount
$RGName = "resourcegroupname"
$SAName = "storageaccountname"
$ConName = "vhds"
$TempObj = New-Object -TypeName PSCustomObject
$TempObj |Add-Member -Name BlobName -MemberType NoteProperty -Value $null
$TempObj |Add-Member -Name LeaseState -MemberType NoteProperty -Value $null
$Keylist = Get-AzureRmStorageAccountKey -ResourceGroupName $RGName -StorageAccountName $SAName
$Key = $Keylist[0].Value
$Ctx = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $Key
$List = Get-AzureStorageBlob -Blob *.vhd -Container $ConName -Context $Ctx
$List | ForEach-Object { $TempObj.BlobName = $_.Name; $TempObj.LeaseState = $_.ICloudBlob.Properties.LeaseState; $TempObj }

Here is the result, we can find the VHD leased (in use) or not: enter image description here

Jason Ye
  • 2,399
  • 1
  • 8
  • 10