Monitor Azure resources creation
You may have noticed that some resource types in Azure don’t provide any creation date property. For instance, if you take a look at a VM properties, you won’t see any creation date field. You can check this by opening the Azure Resource Explorer service and running the following query. When looking at the result, you won’t find any creation date.
Which resource types contain a creation date then?
The answer is simple: resource properties must be analyzed for each resource type. For example, the VMs properties are documented in the Microsoft docs, and as you can see, there is no field for creation date!
Documentation is great, but there are many resource types, so a quicker way is to use the Azure Resource Graph service and look for resources properties that contain one of these two strings: “date” or “time”. This is not a 100% reliable method because, for example, the microsoft.web/sites/slots resource type has the runtimeAvailabilityState property, but obviously, it is not a creation date field. But still, this query is useful because it filters all the resources that don’t have any “date” or “time” string i.e. that probably don’t have a creation date field.
For the remaining resources, we need to manually check if there actually is a creation date field. By manually checking properties of multiple resources, I retrieved a list of creation date field.
Surprising right ? There are at list 12 different creation date fields! To answer our initial question, we can modify this request to return resource types.
How do I monitor other resources?
For resource that do not have any create date field in their properties, you can use Azure Policy. This is a free service that allows you to define and apply multiple policies. For example, you can use such policies to enforce your administrators to deploy only a specific VMs size in order to optimize cost.
In our case, we can create a policy that dynamically create a tag on resource creation : when assigning our policy to a scope (e.g. to a subscription), we name our tag creationDate. So whenever I deploy a resource which is in the selected scope, my Azure policy will add a tag called creationDate, and its value will the current datetime (thanks to the utcNow() function).
We can then modify our previous queries to collect all the creation dates, including the creation date store within our tag. In this example, I named the tag creationDate. You can see that on line 14, the column d13 stores my creationDate tag.
Any chance that I find a workbook to monitor this?
Yes, but I am currently building it may change regularly. You can find it on my Github : here.
Thanks for reading, I hope this was helpful !