Windows Azure Platform Family of articles Catalog
For a-series and D-Series virtual machines, normal storage is used.
Storage resources for normal storage are billed per GB monthly. Microsoft Azure General Storage resources are calculated by how much, and based on average usage.
http://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/ Understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx? Pageindex=2#comments
For example: Virtual machine operating system files, for Windows platform, C disk system disk capacity of 127GB, the operating system actually uses 30GB. Only the 30GB storage that is actually used is charged.
But with the Azure management interface, we can only know the size of the VHD's capacity. Do not know the actual use of capacity.
The author provides a sample Code here to calculate the actual usage capacity of a VHD.
We need to prepare:
1.Azure China Storage Account
2.Azure China Storage account password
Container Name of 3.VHD
4.VHD Name
Save the configuration information in the App. Config file:
<appSettings> <add key="AccountName"Value="Leivms"/> <add key="Accountkey"Value="Storagekey"/> <add key="containername"Value="VHDs"/> <add key="Vhdname"Value="Lei2012chnvm-lei2012chnvm01-2016-01-25.vhd"/> </appSettings>
Sample code is as follows:
Private stringAccountName; Private stringAccountkey; Private stringcontainername; Private voidForm1_Load (Objectsender, EventArgs e) {Calculate (); } Private voidCalculate () {varcontainer =GetContainer (); varCloudpageblob = container. Getpageblobreference (configurationmanager.appsettings["Vhdname"]. ToString ()); //OutPut VHD Actual Size stringActualSize =getformatteddisksize (Getactualdisksize (Cloudpageblob)); } PrivateCloudblobcontainer GetContainer () {//Get config from Web. configAccountName = configurationmanager.appsettings["AccountName"]. ToString (); Accountkey= configurationmanager.appsettings["Accountkey"]. ToString (); ContainerName= configurationmanager.appsettings["containername"]. ToString (); stringConnectionString =generateconnectionstring (); //Get Azure Storage Connection String varAccount =Cloudstorageaccount.parse (connectionString); varClient =Account . Createcloudblobclient (); //Get Blobcontainer Object returnclient. Getcontainerreference (containername); } Private stringgenerateconnectionstring () {StringBuilder Sbuilder=NewStringBuilder (); Sbuilder. Append (@"blobendpoint=https://"); Sbuilder. Append (AccountName); Sbuilder. Append (". blob.core.chinacloudapi.cn/"); Sbuilder. Append (@"; queueendpoint=https://"); Sbuilder. Append (AccountName); Sbuilder. Append (". queue.core.chinacloudapi.cn/"); Sbuilder. Append (@"; tableendpoint=https://"); Sbuilder. Append (AccountName); Sbuilder. Append (". table.core.chinacloudapi.cn/"); Sbuilder. Append ("; Accountname="); Sbuilder. Append (AccountName); Sbuilder. Append ("; accountkey="); Sbuilder. Append (Accountkey); returnSbuilder. ToString (); } Private Longgetactualdisksize (Cloudpageblob pageblob) {pageblob.fetchattributes (); return 124+ PageBlob.Name.Length *2+ pageBlob.Metadata.Sum (m = m.key.length + M.value.length +3) + Pageblob.getpageranges (). Sum (R = A+ (R.endoffset-r.startoffset)); } [DllImport ("Shlwapi.dll", CharSet =CharSet.Auto)] Public Static extern LongStrformatbytesize (LongFileSize, [MarshalAs (UNMANAGEDTYPE.LPTSTR)] StringBuilder buffer,intbuffersize); Public Static stringGetformatteddisksize (Longsize) { varSB =NewStringBuilder ( One); Strformatbytesize (Size, SB, SB.) capacity); returnsb. ToString (); }
Operation Result:
1. In Lei2012chnvm-lei2012chnvm01-2016-01-25.vhd, this page blob has a capacity size of 127GB
2. After running the code, the actual usage capacity of this VHD is 10GB
3. We turn on this Windows virtual machine and display a capacity of C drive of 9.58G
Resources:
http://fabriccontroller.net/calculating-how-much-space-a-windows-azure-disk-is-really-using/
Windows Azure Storage (23) calculates the actual usage capacity of an Azure VHD