Viewing billing in the Azure portal
An important component of using Azure is being able
to view your billing information. If you have an account that allows you a
certain amount of credit, it’s nice to know how much you have left and to view
where the costs are accumulating. To see your current usage, click the
Subscriptions tile in the Dashboard of the Azure portal (Figure 1-17).
Figure
1-17 The Subscriptions tile on the Dashboard of the Azure portal.
Click this tile to go to the Subscriptions blade,
then select the subscription you want to examine. The Subscriptions blade is
displayed. On the bottom of that blade is a tile showing the amount left before
you hit the cap, what the starting credit was, and the burn rate (Figure 1-18).
We can see
that for the account displayed above, the cap is $150 (starting credit), and
$98.52 of that has been used so far. Underneath this graphic is the cost by
resource. This account is taken up by the small web app that is running, but if
there are VMs, storage accounts, and so on, the total cost of each resource
would be displayed here (Figure 1-19).
Figure
1-19 The cost by resource for the selected subscription.
If you click the graphic, it will show the resource
costs by resource in a new blade (Figure 1-20).
Figure 1-20
The details of the cost by resource for the selected subscription.
The
ability to view the billing information on a regular basis is helpful when
managing the costs for your Azure subscription. If you have a subscription with
a monthly credit, you can tell when you’re getting close to the cap. You can
also tell where your costs are accumulating. Also, if you provision some VMs
and forget they’re out there, you’ll be able to see them because they will have
billing associated with them.
Azure
Billing APIs
In
addition to viewing the billing in the portal, you can access the billing
information programmatically through the Azure Billing REST APIs for a specific
subscription. There are two APIs that you can use.
The Azure Usage API enables you to retrieve your usage data. You can fine-tune
the billing usage information retrieved to be grouped by resource if you have
used the resource tags that can be set through most of the Settings screens.
For example, you can tag each of the resources in a resource group with a
department name or project name, then track the costs specifically for that one
tag.
The
Azure RateCard API enables you to list all of the resources that you can use,
along with the metadata and pricing information about each of those resources.
To get you started, there are Billing API code
samples on GitHub that you can download and try out. They are located here:
https://github.com/Azure/BillingCodeSamples.




