Azure Cost Monitor
When using Microsoft Azure services, it's helpful to know how much you're spending on a day-to-day basis. This Azure cost monitor uses the low-power, wireless Adafruit MagTag board to display a daily cost forecast for your Azure subscription.*
This project is intended to show you how to use the Azure cost management API. Take a look at this project and adapt it to fit your needs!
Please note that it's only possible to get a cost forecast -- actual costs are only available once you're billed.
Things used in this project
Software apps and online services
Step 1: Get Azure Credentials
The way we'll get the cost forecast of your Azure subscription is by registering an application on Azure. This allows you to make REST API calls directly from the MagTag using secure credentials. To do this, you'll create a Service Principal using the Azure CloudShell.
1. Log into the Azure portal.
2. Click on the CloudShell icon as shown in the photo above.
If this is the first time you're using CloudShell you'll need to select a storage account to use it with.
Note: using a storage account for this project costs <$0.01 a day.
For more info on CloudShell visit this site.
3. Once the CLI loads type and run:
az ad sp create-for-rbac --name [APP_NAME]Replace "[APP_NAME]" with a name like "cost-monitor"
4. Save Credentials
Copy the APP ID, PASSWORD, and TENANT ID and save into a secure location. We'll need this later for the MagTag's secrets.py file.
Step 2: Install CircuitPython and CircuitPython Libraries
CircuitPython is a derivative of MicroPython designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the CIRCUITPY drive to iterate.
1. Get CircuitPythonfiles.
CircuitPython installation varies depending on which board you're using. Follow the Adafruit Guide for the MagTag to install CircuitPython.
Download the adafruit-circuitpython-bundle-version-mpy-*.zip bundle zip file, and unzip a folder of the same name. Inside you'll find a lib folder. The entire collection of libraries is too large to fit on the CIRCUITPY drive. Instead, add each library as you need it, this will reduce the space usage but you'll need to put in a little more effort.
You will need a few libraries for this project. Be sure that you have the following libraries in the CIRCUITPY/lib directory on your MagTag:
Azure Cost Monitor
Code for programming the Adafruit MagTag (or other ESP32S2 board) to monitor costs for your Azure subscription.
Latest commit to the master branch on 2-3-2021
Dabbled in dark matter, settled into engineering w/ a blend of inventing and education! Sr.PM @ Microsoft Founder/CEO of FoxBot Industries.
Software Engineer at Microsoft, working in the Office of the CTO. Exploring what the future of maker technologies hold.
This content is provided by our content partner Hackster.io, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.