Reading Time: < 1 minute

Resource Tags are a great tool when it comes to organizing your resources. A resource tag consists of a tag name and a value pair. That simple! There are times though, where you wish you had added a tag and a value that stated the exact creation time of the azure resource.

With Bicep it’s actually quite easy!

In order to use a date-time value and pass it as a resource tag value, all is needed is to create a parameter combined with the function utcNow. This function returns the current (UTC) date-time value in the specified format.

utcNow()ISO 8601 date formatstring20190305T175318Z
utcNow(‘d’)Short date formatstring03/05/2019
utcNow(‘M d’)Custom date formatstring3 5
Output example for various formats

If no format is provided, the ISO 8601 (yyyyMMddTHHmmssZ) format is used.

The following example illustrates the deployment of a resource group, with resource tags specified, in which date-time value among them.

The parameter dateTime is accompanied by function utcNow(‘d) which d (format) stands for the returned day in short date-time format, for example, this would result in a format like “08/11/2021”.

In order to pass this value into a resource tag value, I just need to reference the parameter instead of providing a string value. See line number 10, CreationDate: dateTime.

Let’s find out how it looks like.

Additional information regarding the date functions can be found here.

Thanks for reading my blog!

Feel free to drop your comment or question below.