Azure Enterprise Agreement Billing API And Billing Updates

In this post I’m going to have a look at the Azure Enterprise Agreement Billing API and billing updates. The updates enable emailing invoices and some PowerShell cmdlets to retrieve invoices.

Emailing Invoices

You can opt in to receive your monthly invoice via email, which beats logging into the portal to download them every time. You’ll find the options to configure recipients on the Invoices menu in the Subscriptions blade.

InvoicesBlade

This feature is only available to consumer Azure subscriptions.

PowerShell Invoice Cmdlet

The Get-​Azure​Rm​Billing​Invoice cmdlet that provides the ability to download invoices is currently in preview. Before you can successfully use the cmdlet you have to enable access to your invoices in the Subscription blade of the Azure Portal.

InvoiceCmdLets

By default users with Subscription administration access will be able to retrieve invoices. You can grant other users access by assigning the Billing Reader role to users from the Access Control menu on the Subscription blade.

BillingRBAC

Calling the Get-​Azure​Rm​Billing​Invoice cmdlet doesn’t return the actual invoice but rather an Invoice object that contains amongst others a DownloadURL property that you can use to download the invoice. Note the URL is valid for 1 hour.

Login-AzureRmAccount
 $inv = Get-AzureRmBillingInvoice -Latest
 Invoke-WebRequest -Uri $inv.DownloadUrl -OutFile C:\Temp\Invoice.pdf

This feature is only available to consumer Azure subscriptions.

Invoice Retrieval For Enterprise Agreement Customers

If your are an EA customer the above method won’t work for you but you can download your usage and charges using the Billing Rest API for EA customers. In some respects this is easier for EA customers since the dataset returned contains usage and charges, you don’t have to calculate it separately. Before using the API you have to get your API key from the EA portal.

EA

You can find out more about using the API in this channel 9 video which also contains this link in the show notes that describes the API.

PowerBI Integration With The EA Portal

You can also export your billing data to PowerBI from the EA portal using the Power BI Reporting tab on the Reports menu. This functionality is provided by the Power BI Enterprise Pack, although it is a manual process to export data the first time, you can schedule the dataset to refresh automatically, more here and you can subscribe to report emails, it is in preview so the functionality is still evolving, more here.

Retrieve Usage Using PowerShell Cmdlets

The Get-UsageAggregates cmdlet is not a new feature but I didn’t get a chance to cover it yet. You can use it to retrieve resource usage, take note that the cmdlet makes use of a continuation token since the dataset can be quite large if you download detailed usage. Your billing charges can be calculated by retrieving the rates separately using the RateCard API and matching it to your usage, I covered the RateCard API in a previous post. The Get-UsageAggregates cmdlet is available to consumer Azure subscriptions and Enterprise Agreement subscriptions but the RateCard API is for consumer Azure subscriptions only.

Francois Delport

Published by

Francois Delport

I am a cloud and devops consultant, technology fan and previously a professional C# developer with a keen interest in system design and architecture. Currently I am involved in projects using Azure, the Microsoft stack and DevOps. I am based in Melbourne, Australia. Email: [email protected]

Leave a Reply

Your email address will not be published. Required fields are marked *