Azure like chargeback with System Center & Windows Azure Pack – Part 1

Since the release of Windows Azure Pack a frequently asked question is about the chargeback in Windows Azure Pack. I have heart the question a thousand times why Microsoft does not provide us with the chargeback and billing system from Azure for Windows Azure Pack.

Azure_Portal

The answer is not that easy and I’m not willing to discuss it here in my blog. But I will show you something how you can provide your tenants with an Azure like chargeback just only with System Center & Windows Azure Pack. Before you leap for joy I have to disappoint you. It is not a solution like Cloud Cruiser or Cloud Assert with Resource Providers for the Admin and Tenant Portal.

-> http://www.cloudcruiser.com/partners/microsoft/
-> http://www.cloudassert.com/Solutions/Usage

It is a solution which automatically generates a chargeback report for the tenant with its monthly costs and will send them an email. That is it for the beginning. I have plans for a solution that will be generating a daily usage report and will send the tenant an email. But let us start first with the monthly chargeback & billing report.

The requirements are the following components for our usage metering & reporting and our chargeback solution.

  • Windows Server 2012 R2 Hyper-V as hypervisor
  • System Center 2012 R2 Virtual Machine Manager
  • System Center 2012 R2 Operations Manager
  • System Center 2012 R2 Service Provider Foundation
  • System Center 2012 R2 Service Management Automation
  • System Center 2012 R2 Service Reporting
  • Windows Azure Pack
  • PowerShell

First of all you have to understand the usage metering flow.

Usage_Flow

We are starting at the Hyper-V hosts whereon the VMM agent and the SCOM agent are installed. All information how long the VMs are running etc. are send to or gathered by the VMM management server. The VMM management server is connected with SCOM and pushes the data every hour to the SCOM server. The SCOM server stores the data in its own data warehouse. The Windows Azure Pack usage collection cycle triggers every nine minutes the Service Provider Foundation to collect the data from the SCOM data warehouse. Then the data is temporary stored at the SPF database before the WAP usage collection cycle transfers the data into the WAP database. Finally Service Reporting collects the data from the WAP database, transfers the data to its own database, analyzes and processes them for chargeback & billing. But and that is very important Service Reporting does not create a chargeback & billing report. Before we move on have a look at the following table with the time frames how long the usage & metering data are stored in the different databases.

DatabaseTime frame
VMM1 month
SCOM data warehouse1 year
SPFTemporary. Only the last entry will be stored until the next collection run.
Windows Azure Pack40 days
Service Reporting hourly data90 days
Service Reporting daily data3 years
Service Reporting monthly dataIndefinitely

The next essential step is to understand what costs an Azure VM generates. There are four parts.

  • Compute or runtime is charged per hour
  • Used storage is charged per GB per month
  • Storage transactions per 100.000 transactions
  • Outgoing traffic is charged per GB

We want an Azure like chargeback so we go in general with all four parts. But in my demo lab I do not have the Network Virtualization set upped right now and that is the reason why I am skipping the outgoing traffic in my examples.

In comparison to Azure we have a whole lot more KPI’s to do our chargeback with Service Reporting. The important ones for us for an Azure like chargeback are the following ones.

  • TotalVMRuntime
  • DiskSpaceUsage
  • DiskIOPS
  • CoreAllocated
  • MemoryUsage

Chargeback01

We will use in our example the monthly KPI’s.

Next step is to have a look at the VM role sizes which are defined in the VMM database. Open a PowerShell console on the VMM management server and execute the Get-CloudVMRoleSizeProfile cmdlet. I always change the VM role sizes in my demo lab to the following values.

CPU coresMemory
ExtraSmall11.024
Small22.048
Medium24.096
Large44.096
ExtraLarge48.192
A688.192
A7816.384

$VMRoles=Get-CloudVMRoleSizeProfile
foreach($VMRole in $VMRoles)
{
if($VMRole.Name -eq “ExtraSmall”)
{
Set-CloudVMRoleSizeProfile -CPUCount 1 -MemoryMB 1024 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “Small”)
{
Set-CloudVMRoleSizeProfile -CPUCount 2 -MemoryMB 2048 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “Medium”)
{
Set-CloudVMRoleSizeProfile -CPUCount 2 -MemoryMB 4096 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “Large”)
{
Set-CloudVMRoleSizeProfile -CPUCount 4 -MemoryMB 4096 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “ExtraLarge”)
{
Set-CloudVMRoleSizeProfile -CPUCount 4 -MemoryMB 8192 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “A6”)
{
Set-CloudVMRoleSizeProfile -CPUCount 8 -MemoryMB 8192 -VMRoleSizeProfile $VMRole
}
if($VMRole.Name -eq “A7”)
{
Set-CloudVMRoleSizeProfile -CPUCount 8 -MemoryMB 16384 -VMRoleSizeProfile $VMRole
}
}

The VM role sizes are the basis for our cost definition and compute charging. Based on the VM role sizes the cost definition depends on the environment and cannot be generalized. It is a task you have to do every time for the specific environment. As I said we want an Azure like chargeback so let us start with the costs for storage and storage transactions. I adopt the costs from Microsoft Azure in the North Europe region.

  • Microsoft Azure Local Redundant Storage: 0,0373€ per GB per month
  • Microsoft Azure Storage Transactions: 0,0027€ per 100.000 transactions

-> http://azure.microsoft.com/en-us/pricing/details/storage/

That was the easy part. For the compute costs it is a bit difficult.

CPU coresMemorySimilar Azure VM sizeAzure VM compute costs per hour
ExtraSmall11.0240,050275€
Small22.0480,10055€
Medium24.096A20,1341€
Large44.096(A3+A2)/2=0,2011
factor ~ 1,3…
ExtraLarge48.192A30,2681€
A688.1920,4022€
A7816.384A40,5362€

First I have figured out which Azure VM size is similar to one of my VM role sizes and I could easily identify three of them and have the compute costs per hour. For the rest I had to sum up the costs for A3 & A2 and divide with 2 to get my compute costs for the Large VM role size. The cost factor from Medium to Large is nearly 1,3. But we will use the accurate value 1,333167578319244. At this time I could easily calculate the costs for ExtraSmall, Small and A6.

Now we have all pieces together to do an example chargeback. But before we move on let me explain to you how the data is presented by Service Reporting. Remember we will use the KPI’s TotalVMRuntime, DiskSpaceUsage, DiskIOPS, CoreAllocated and MemoryUsage. Service Reporting presents you the data in units and a unit in Service Reporting is 15 minutes. That is to say that an hour consists of four units. Here is an example. We have a VM with 2x CPU cores, 2.048 MB memory and 60 GB fixed size VHD. The VM runs for an hour. Have a look at the table how Service Reporting aggregates the data.

TotalVMRuntimeCoreAllocatedMemoryUsageDiskSpaceUsage
122.04860
244.096120
366.144180
488.192240

As you can see you have to divide the TotalVMRuntime with 4 to get the value in hours how long the VM has been running in the current period. Let us have a look for a more real world example. Our current chargeback period is January 2015. For that I have extracted the data of the VM DC-1.neumanndaniel.local.

Chargeback01

The VM DC-1.neumanndaniel.local has 2x CPU cores, 2.048 MB memory and 305 GB fixed size VHDs. The data of that VM out of Service Reporting are the following ones:

  • TotalVMRuntime: 33
  • DiskSpaceUsage: 10.109 GB
  • DiskIOPS: 126.126
  • CoreAllocated: 66
  • MemoryUsage: 67.584 MB

Have a look again at out pricing and let us calculate the costs for the VM.

Pricing:

  • Compute (per hour, CPU:Memory ratio = 1:1): 0,050275€
  • Compute (per hour, CPU:Memory ratio = 1:2): 0,050275€ * 1,333167578319244
  • Storage (per GB per month): 0,0373€
  • Storage Transactions (per 100.000): 0,0027€

Compute: (33/4) * (66/33) * 0,050275€ = 0,8295375€
Storage: (10.109/33) * 0,0373€ = 11,42623333333333€
Transactions: (126.126/100.000) * 0,0027€ = 0,003405402€

Total costs: 12,26€

For the chargeback period January 2015 the VM costs us 12,26€ and the VM was running 8,25 hours.

For the summary here the formula I have used above to calculate the costs.

Compute: (TotalVMRuntime/4) * (CoreAllocated/TotalVMRuntime) * Compute pricing
Storage: (DiskSpaceUsage/TotalVMRuntime) * Storage pricing
Transactions: (DiskIOPS/100.000) * Transaction pricing

I hope you got some insights on how you can provide an Azure like chargeback with System Center & Windows Azure Pack. In part 2 of “Azure like chargeback with System Center & Windows Azure Pack” I will show you how to query the OLAP cube of Service Reporting with PowerShell, how to automatically generate a chargeback & billing report and send them via email to the Tenant.

Stay tuned!

If you need support on how to setup & configure the usage metering & reporting flow have a look at the following links.

-> http://www.danielstechblog.de/iaas-usage-metering-reporting-mit-system-center-2012-r2-windows-azure-pack/
-> http://www.danielstechblog.de/windows-azure-pack-iaas-usage-metering-reporting-troubleshooting/
-> http://www.danielstechblog.de/system-center-2012-r2-service-reporting-troubleshooting/

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply