Using the Azure Billing API with Powershell

Once you’ve got an Enterprise Agreement with Microsoft Azure, you’ll probably want to know how much you’re spending.

As with everything Azure, you’re better off forgetting the UI and using Powershell.

Unfortunately, the billing API doesn’t return detailed information in a Json or xml format – it is a long string delimited by commas and linebreaks.

Before we can do anything with the detailed data we get from the API we need to clean it up into a powershell object.  Once we have a usable object to work with then we can start playing with the billing data.

In the example below, I’ve used the sample data account (Enrollment #100), just plug in your own enrollment number and the access key from the Azure Enterprise Site and you’ll be away.
For full documentation on the EA API, you can find the API guide here

Convert a Powershell hashtable to object

I’ve struggled on a few occasions of being lumbered with a hashtable that i’d created for whatever reason (usually because it’s so damn quick and easy).
Having my roots in OO development, I inevitably want to start dealing with objects at some point.

Long story short, here you go 🙂

Using the Statuscake API with Powershell

Having set up a few URL monitors with Statuscake, I needed to get the data out to start playing with it in Microsoft Excel/PowerQuery.
There are 3 sets of data that i’m extracting with the script below.

    Location data
    Test definition data
    Test Performance data

On top of the basic API calls to Statuscake I wanted to enrich their Location data with actual Geo data that could be used in a BI visualisation. For this i’m using FreeGeoIP.