One of the great benefits of Azure (and the Cloud in general) is the simplicity with which you can create and scale resources. The downside to this is that you can easily lose track what you’ve got deployed, or accidentally create expensive items and leave them running.
We wanted a way to track our spending on a daily basis so we could keep tabs and detect any unusual spikes in costs. Previously, we were relying on Azure billing but this meant that costly resources could have been running for up to 2 months before we were notified.
Fortunately, Microsoft recently added the Azure Cost Management service (by Cloudyn). This is a free service which updates daily with reports detailing the breakdown of your assets and costs in Azure.
To set it up, go to the Azure Portal, select ‘Cost Management + Billing’ -> ‘Cost Management’ -> ‘Go to Cost Management’.
This will open up the Cloudyn site in a new tab, and from here you can configure the service to monitor your subscriptions.
There are slightly different steps depending on how your subscriptions are managed – the Azure documentation page has quick step guides for each subscription type: individual subscription owner, EA, and CSP.
N.B. If you have Microsoft Sponsorship subscriptions like we did, follow the steps for ‘individual subscription owner’ and select the ‘MS-AZR-0003P – Pay-As-You-Go’ offer ID – this will show you what your spend would be if it were not discounted.
As part of the setup you will need to grant access to Cloudyn to read your resources and billing information. Once this is done, the service will start gathering data about your assets and costs. The documentation suggests that it can take up to 24 hours for the first data to appear – in practice, we found we actually had to wait around 48 hours, so don’t despair if nothing happens straight away.
When you have data flowing, you can generate all sorts of reports related to your costs, drilling down into specifics like service providers and resource types. The one we were particularly interested in was the rolling total of spend over the last 30 days, with costs broken down by day. This allows us to spot anomalies and general spending trends before they get out of control.
Once you have configured any report, you can set up a schedule for it to be emailed out on a daily, weekly, or monthly basis, so you don’t have to remember to come back to the dashboard all the time.
With the help of Cloudyn, we were able to reduce our projected Azure spend for the year by $10,000.
BONUS – Configuring alerts in Slack
We spend a lot of time in Slack at endjin, and it has become our central place for alerts across all sorts of things, from CI/CD notifications, to whether our security cameras are working. So whilst email alerts for Azure costs are good, Slack alerts would be better.
Now Cloudyn doesn’t have any native support for Slack or webhooks, but what we did make use of was Slack’s email integration. With the Slack Email app, you can create an email address which will forward all emails sent to that address to the Slack channel of your choosing. You can even customize the name and avatar that gets used when posting the message.
We simply configured Cloudyn to send out the report to a Slack email address we generated, and now we have a daily report in our #azure channel alerting us to our spending trends in Azure.