Provision the CreatedOnDate Tag using Azure Policy

Resources created in Azure are not by default tagged with a creation date property. Adding this tag is great for auditing purposes. 

Its important to keep track whom and when resources are deployed for chargeback and accountability purposes. Applying this CreatedOnDate tag to a resource will exist for the life of the resource, especially since the Azure Monitor default retention period is only 90 days and instead of provisioning Log Analytics Workspaces with larger retention periods for this purpose when tagging is free.

New Policy Definition > Management Group T1 
Name Tag Compliance - Tag - CreatedOnDate
Description
Category

{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "tags['CreatedOnDate']",
          "exists": "false"
        }
      ]
    },
    "then": {
      "effect": "append",
      "details": [
        {
          "field": "tags['CreatedOnDate']",
          "value": "[utcNow()]"
        }
      ]
    }
  },
  "parameters": {}
}

3 comments

  1. Normally I do not read article on blogs, but I wish to say that this write-up very forced me to try and do so! Your writing style has been amazed me. Thanks, very nice post.

Leave a comment

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