How do I reclaim unused blob space for my Azure VHD - azure

Maybe I don't fully understand how Azure charges for VHD storage.
When I started out, I had a 120gb VHD with only ~30gb used. I was only getting charged for roughly 1gb per day for Azure. As I filled up the hard drive, the daily usage grew as expected. I ended up using 100gb of the drive and was getting hit with roughly 3.6gb per day from Azure. That makes perfect sense to me.
The other day, I free'd up a lot of space on the VHD and now I only use 30gb again where the other 90gb is free space. However, it seems that I'm still getting charged for roughly 3.6gb per day.
Could someone help explain this to me? Do I need to do something to reclaim the free space? If so, how?
Thanks

It's now possible to manually reclaim unused space by executing the following PowerShell command (starting from Windows Server 2012 / R2):
Optimize-Volume -DriveLetter F -ReTrim
More information: Release unused space from your Windows Azure Virtual Hard Disks to reduce their billable size

Even though the files on the VHD may be deleted, you still pay for the space they once consumed. Check out this post by the Windows Azure storage team - http://blogs.msdn.com/b/windowsazurestorage/archive/2012/06/28/exploring-windows-azure-drives-disks-and-images.aspx.
In the "Storage Capacity" section -
"It is also important to note that when you delete files within the file system used by the VHD, most operating systems do not clear or zero these ranges, so you can still be paying capacity charges within a blob for the data that you deleted via a disk/drive."

Related

Azure will not let me swap to my new smaller OS disk

Good Morning, Fellow Stack Overflow-ers,
I have a Windows 2019 DC Virtual Machine with a 127GiB OS Disk with MS Azure. The WM image is Standard B2s (2 vcpus, 4 GiB memory)
I want to swap this with a smaller 8GiB OS disk - having successfully created this in my portal and labelled useastOS - Azure is failing to allow me to swap from the previous 127GiB disk to the smaller 8GiB Disk. On the "Swap OS Disk" menu illustrated, you will see there is no option to use the useastOS disk.
Puzzling.
This is a managed disk and so there is no reason whatsoever as to why Azure is not giving me the option.
So my question is there any valid reason as to why Azure is not allowing me to swap to the smaller useastOS or is this bug within Azure that I need to make Azure aware of?
When you are creating a Managed Disk like this, there is no SO installed, it is an empty disk, that's why Azure assumes it is a data disk, not a SO disk.
Now, when you upload your VHD disk to blob storage, you can tell Azure that this disk is OS and not a data disk like this.
Looking for upload VHD to Azure blob, here it is an example https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image.
Your question is how to swap SO disk to a new one smaller, this is what I understood, in case you just want to add a second disk as a data disk, you can go to VM overview, from blade disk, you can add it easily.
Anyway, I hope that I could help in any :)
Just in case, confirm that you selected an operation system when you created this disk useastOS. For example, in my case it is Windows, but disk can be either Windows or Linux, when you don't select anything, Azure assumes it is a data disk, not an operation system.

What are the data disks used for?

I need to know the difference between the SSD disk and the data disk. According to this capture, this virtual machine has a hard disk ssd 16gb, and 4 disks data. But these 4 disks, how much do they have? Are they ssd? what are they for?
enter image description here
data disks can be ssd or not, depending on how you set them up. they are used to store data :)
amount of data disks you can attach depends on the vm sku. you dont always have to attach 4 data disks (or whatever vm supports, you can have 0 - VM SKU maximum data disks).
The 16gb ssd is local ssd (local to the host machine hosting your vm) attached to the VM (not OS disk). its a temporary drive - meaning it can go away when you reboot vm, so content will be lost and you will get a new temporary drive. it can be used to store throw away logs, for example, or temporary files. IO operations on this disk do not count towards IO limit and this drive is completely free (you pay for the VM SKU and it is part of that cost).
you can learn about data disk prices here: https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Storage prices do not take into account os or data disks. they just bill you for storage.
reference:
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/attach-managed-disk-portal
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps
It means in addition to the OS disk, you can connect 4 data disks to the VM.
It does not mean there are 4 disks, just that you can add 4 if you want.
You should discuss the VM requirements with your client. Maybe he needs an additional data disk, maybe not.
The capture you posted, specifies that this VM can take up to 4 data disks. The price does not include them. Also, you should check the Azure price calculator to generate more accurate offers.

Windows Azure - HDD Size

I am playing with Windows Azure to create an small VM to host a service that almost doesn't take any space.
Windows Azure creates a default 130gb disk, with about 100gb free. That's way too much. I do not need that much space.
I understand that MSFT will charge the storage (ie: the 130gb), so I would like to create the VM smaller (probably 30 or 40gb).
Is it true that MSFT will charge me for the unused space?
Is there a way to create the machine the size I want?
If there is no way to create the machine in the size I want, how to resize? (the option to download the .vhd to my computer, resize locally and upload looks way too much effort to say the less).
Is it true that MSFT will charge me for the unused space?
Not true. This is because Virtual Machines are essentially Page Blobs and page blobs are charged based on the occupied bytes instead of total size. So even if a 130 GB disk is created for you and let's say you fill it with 30 GB of data, you'll only be charged for 30 GB instead of 130 GB. Please note that for block blobs you're charged for the size of the blob even if it's empty. You can read more about blobs here: http://msdn.microsoft.com/en-us/library/windowsazure/ee691964.aspx.
Is there a way to create the machine the size I want?
Currently no, but given that you're not charged for the unused space I don't see any reason why you would want to do that.
If there is no way to create the machine in the size I want, how to
resize?
Page blobs are resizable. Do take a look at this blog post on how to resize a page blob (and thus a VM image): http://blog.maartenballiauw.be/post/2013/01/07/Tales-from-the-trenches-resizing-a-Windows-Azure-virtual-disk-the-smooth-way.aspx

Can I create Windows Azure drive as 1T size straight way

The max size for Windows Azure drive is 1T
M$ only charged for the data in it, not for the size
My question is: why not just create an Azure Drive at size 1T, so no more worries about resize etc.
Or there has catch if I create a Drive bigger than I need.
I often do that when creating an Azure Drive: allocating a maximum size drive of 1TB. No discernable penalty. The only advantage to setting a smaller size: protecting yourself against cost overruns. There might be a possibility it takes longer to initialize a 1TB drive, but I haven't measured it.
I have not yet found a lot of use for Azure Drives given some of the limitations that they have and the other storage options that are available, so I have only done some playing with them, not actually used one in a production environment.
With that said, based on my understanding, and the description you give in your question about only being charged for the amount of content stored on the drive I do not see any issue with creating a large drive initially and growing into it in the future.
Hope that helps some, even if it is just a - yes I think you understand it correctly!
The reason is pretty simple if you tried it. Namely, while you are not charged except for the data inside the drive, it does count against your quota limit. So, if every drive was 1TB, then you could create only 99 drives (think overhead here) before your storage account quota was gone. Also, yes, it does take longer to create a 1TB drive versus a smaller one (in practice).

How do I increase the size of an Azure CloudDrive?

I have an existing Azure CloudDrive that I want to make bigger. The simplist way I can think of is to creating a new drive and copying everything over. I cannot see anyway to just increase the size of the vhd. Is there a way?
Since an Azure drive is essentially a page blob, you can resize it. You'll find this blog post by Windows Azure Storage team useful regarding that: http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/11/using-windows-azure-page-blobs-and-how-to-efficiently-upload-and-download-page-blobs.aspx. Please read the section titled "Advanced Functionality – Clearing Pages and Changing Page Blob Size" for sample code.
yes you can,
please i know this program, is ver easy for use, you can connect with you VHD and create new, upload VHD and connect with azure, upload to download files intro VHD http://azuredriveexplorer.codeplex.com/
I have found these methods so far:
“the soft way”: increase the size of the page blob and fix the
VHD data structure (the last 512 bytes).
Theoretically this creates unpartitioned disk space after the
current partition. But if the partition table also expects
metadata at the end of the disk (GPT? or Dynamic disks), that
should be fixed as well.
I'm aware of only one tool
that can do this in-place modification. Unfortunately this tool is
not much more than a one-weekend hack (at the time of this writing)
and thus it is fragile. (See the disclaimer of the author.) But fast.
Please notify me (or edit this post) if this tool gets improved significantly.
create a larger disk and copy everything over, as you've suggested.
This may be enough if you don't need to preserve NTFS features like
junctions, soft/hard links etc.
plan for the potential expansion and start with a huge (say 1TB) dynamic VHD,
comprised of a small partition and lots of unpartitioned (reserved) space.
Windows Disk Manager will see the unpartitioned space in the VHD, and can expand the
partition to it whenever you want -- an in-place operation. The subtle point is
that the unpartitioned area, as long as unparitioned, won't be billed, because
isn't written to. (Note that either formatting or defragmenting does allocate
the area and causes billing.)
However it'll count against the quota of your Azure Subscription (100TB).
“the hard way”: download the VHD file, use a VHD-resizer program to insert unpartitioned disk space, mount the
VHD locally, extend the partition to the unpartitioned space, unmount,
upload.
This preserves everything, even works for an OS partition, but is very
slow due to the download/upload and software installations involved.
same as above but performed on a secondary VM in Azure. This speeds up
downloading/uploading a lot. Step-by-step instructions are available here.
Unfortunately all these techniques require unmounting the drive for quite a lot of time, i.e. cannot be performed in high-available manner.

Resources