Time Functions in ARM Templates

Time Functions in ARM Templates

There has been a need for a while now to have time Functions within ARM templates which has historically been convoluted and could not be down within the ARM template itself. I have had this need for a while as I typically pass the deployment datetime as a value to Tag resources with. Previously I have had to use PowerShell to get my date time and passed this to my ARM Deployment. Well, this is no longer required as Microsoft have released support do be bale to do this natively within the ARM template.

utcNow Function

Microsoft have now released support for the utcNow Function within ARM templates which allows us to get a nicely formatted ISO 8601 datetime string without having to do much work at all. A thing to note is that this function can ONLY be used within the default of a parameter. So, this is how it looks in its simplest form.

AS you can see we call the utcnow() function and wrap that within the ‘strutcValue’ parameter. Here is the complete example with the output.

Now we can can one step further here and apply some custom formatting to our utcNow() function to produce differently formatted date times. A few examples are:

  • Custom format for Year-Month-Date: [utcNow(‘y-M-d’)]
  • Short date format: [utcNow(‘d’)]
  • Just the time (24hour): [utcNow(‘t’)]
  • Long date time: [utcNow(‘s’)]
  • The month and date: [utcNow(‘m’)]

Here is the complete example and output.

Showing the 6 different examples of datetime


As you can see that with the utcnow() function it is very easy to add time stamps natively via ARM deployments. I hope you found this blog useful. Feel free to leave any comments.

Leave a Reply

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