SQL Azure provides us the following system view “sys.database_usage”to get the details of database quantity used per day
How to calculate Daily Cost Usage ?
1: /* How to calculate Daily Cost of DB Usage */
3: SELECT time, sku, quantity,
4: CASE sku
5: when 'Web' THEN Quantity * (9.99 / 30)
6: WHEN 'Business' THEN Quantity * (49.99 / 30)
7: END AS DailyCostofDB
8: FROM sys.database_usage order by time
How to calculate Monthly cost of Database Usage ?
1: /* How to calculate Monthly Cost of DB Usage */
3: SELECT CAST(datepart(yy, TIME) AS Varchar) + ' - ' + DateName(mm, TIME) [Billing Month],
5: SUM ( CASE WHEN USAGE.SKU = 'Web'
6: THEN (Quantity * 9.99/30)
7: WHEN USAGE.SKU = 'Business'
8: THEN (Quantity * 99.99/30)
9: END ) AS CostInDollars
10: FROM sys.Database_Usage USAGE
11: GROUP BY CAST(datepart(yy, TIME) AS Varchar) + ' - ' + DateName(mm, TIME), SKU
12: ORDER BY CAST(datepart(yy, TIME) AS Varchar) + ' - ' + DateName(mm, TIME)
You can use this queries in a SSIS Package to collect data from SQL Azure on daily basis and store it in local server and prepare reports across various different SQL Azure servers
I hope you all find this useful to monitor the cost of SQL Azure database usage
2 thoughts on “How to monitor SQL Azure Database Usage Cost on daily basis by yourself”
Does this still hold true? I think the costs have changed since you wrote this (not sure)?
The pricing structure has changed a lot since I wrote this post, Please refer this article for updated information http://msdn.microsoft.com/en-us/library/windowsazure/jj136829