Email report of costly activities in Azure
It is very easy to accumulate spend if resources are not being managed in the correct way e.g. keeping VMs on when they are not required, having resources set to the incorrect scale or resources being created for testing and never being deleted.
This seemed a simple ask, but there wasn't a simple answer. You can use Activity Logs and filters to only see Administrative tasks in the portal, but there are just so many of them, it is difficult to produce something valid. You cannot even use the proper Operation name, only the localizedstring value.
|Just a snippet|
Create (as in creation of new VM)
Deallocate (turning off a VM)
Write (again similar to Change and Update)
I created a PowerShell Script which would produce this in a CSV and email it to my colleague on a nightly basis for events in the last 24 hours. There is the potential that this would create some false positives, but having it in CSV means they can filter what they want.
Below is the final script. If you want to re-purpose it, you will need an SMTP server. You will need to ensure the SMTP credentials are stored in your Automation Account. This allows you to keep your credentials private by not having them in plain text. Of course, plain text will work, but don't do that....seriously!