Microsoft added the possibility to choose the time zone along with the schedule time (which is great to avoid Daylight Saving Time changes), so I wanted to include this in my template deployments too. Because I found some troubles to find the information I needed (because I couldn’t find how to do it in different API reference pages) and I finally managed to do it, I think it would be good to share the solution with you all.
To set the time zone using the Azure Portal is as easy as selecting the time zone from a drop down list:
With Azure PowerShell you also have the ability to do this using the “New-AzureRmAutomationSchedule” cmdlet along with the “-TimeZone” parameter.
But, let’s see how to do this with templates. This is the code I use to create a schedule with a template (I create the automation account within the same template and that’s why you see “concat” instead of references to the automation account resource in Azure):
"name": "[concat(parameters('accountName'), '/', parameters('scheduleName'))]",
"description": " ",
The key here is the “timeZone” property. This property is the one I couldn’t find in the “official” documentation and the one which allows to set a time zone for your schedule object. This property accepts a string that can be the IANA ID or the Windows Time Zone ID for the time zone you want (POSH command works the same way). In my case I wanted to use the UK Time and I prefer to use IANA format, because in my opinion it is easier to visualize which zone are you setting. So, this is what I type as my “scheduleTimeZoneId” parameter:
Last but not least, as an additional tip, I wanted to explain how the “startTime” parameter works. It establishes the start time in UTC format, what it means that if you set the start time to 10:00 a.m. during the deployment today, what you will see in the schedule on Azure will be 11:00 a.m. because in London we are UTC+1 right now (April = summer time). For this reason, I recommend writing the string with the time using the DateTimeOffset format to avoid a little the confusion this can cause. Since I know I’m on UTC+1 at this moment, I set the “scheduleStartTime” value like this:
This way when I look at the schedule created on Azure I will see the same date and time I chose on my template.
I hope this helps and I see you in the next post! Do get in touch if you have any questions, we're happy to help!