Hello! In our last lesson, we explored how to connect functions to other services using input and output bindings. You saw how a simple HTTP request could trigger a workflow that reads from or writes to a database, all with minimal code.
Today, we'll shift our focus from user-initiated triggers to automated, scheduled tasks. This lesson directly addresses the learning outcome: Implement a timer-triggered Azure Function using a CRON expression. You will learn how to create functions that run on a schedule, a fundamental pattern for background jobs like nightly data processing, generating reports, or system maintenance tasks. This is a common requirement and a key topic for the AZ-204 exam.
We'll start by diving into the scheduling mechanism itself—CRON expressions—and then build, configure, and deploy a .NET function that runs on a timer.
1. Understanding the Timer Trigger
A timer trigger executes your function based on a schedule. In Azure Functions, this is configured using the TimerTrigger attribute in your C# code. The most important property of this attribute is the schedule itself, which is defined using an NCRONTAB expression.
NCRONTAB is a slightly extended version of the standard CRON format, adding a sixth field at the beginning to specify seconds.

Let's look at the official documentation to understand the structure of these expressions and the TimerTrigger attribute.
Timer trigger for Azure Functions
This official Microsoft Learn documentation is the definitive guide for timer triggers. It details the scheduling format and C# implementation.
Start with the section "NCRONTAB expressions". Pay close attention to the six fields: {second} {minute} {hour} {day} {month} {day-of-week}. Study the table of examples under "NCRONTAB examples" to see how these fields combine to create common schedules. Next, review the "Example" section. Since you are using the .NET Isolated Worker model, focus on the code under that tab. You'll see the [TimerTrigger] attribute in action. Finally, look at the "Attributes" section. Read the descriptions for the Schedule, RunOnStartup, and UseMonitor properties. These are key for configuring your trigger's behavior.
2. Mastering CRON Expressions
The power of the timer trigger lies in the flexibility of CRON expressions. While the documentation gives some examples, a deeper understanding of the syntax will allow you to define any schedule you need.
The following video from John Savill provides an excellent, detailed explanation of how to construct CRON expressions, from basic fields to advanced operators.
In this video, "cron Expressions," John Savill breaks down how to build schedules from scratch.
Watch the following segments to get a comprehensive understanding: Field Order and Values: This part covers the standard five fields (minute, hour, day of month, month, day of week) and their value ranges. Remember that Azure Functions adds a second field at the beginning. Wildcard and Any: Learn the difference between the * (all) and ? (any) special characters. Increments, Lists, and Ranges: This is crucial. It explains how to use the / operator for intervals (like "every 5 minutes"), the , for lists (like "at 10am and 2pm"), and the - for ranges (like "Monday through Friday"). Using Validators: The video highlights online tools for validating your CRON expressions, which is a great practice to ensure your schedule is correct before deployment.
Here's a quick summary of the most common operators you'll use:
| Operator | Description | Example | Meaning |
|---|---|---|---|
* |
Selects all values within a field. | 0 * * * * * |
At the start of every minute. |
, |
Separates values to form a list. | 0 0 8,17 * * * |
At 8:00 AM and 5:00 PM every day. |
- |
Defines a range of values. | 0 0 9 * * 1-5 |
At 9:00 AM every weekday (Monday to Friday). |
/ |
Specifies an increment or step. | 0 */15 * * * * |
Every 15 minutes. |
3. Creating and Deploying a Timer-Triggered Function
Now let's put this knowledge into practice. You'll create a new timer-triggered function, write some simple C# code, and deploy it to Azure. Given your extensive background in .NET, this process will feel very familiar.
The following video provides a practical, step-by-step demonstration of creating and deploying a timer-triggered function using Visual Studio. The steps are very similar if you prefer to use VS Code with the Azure Functions extension.
Azure Function: Creating and Deploying HTTP Triggers and Timers to Azure using Visual Studio | LSC
This video from Learn Smart Coding, "Creating and Deploying HTTP Triggers and Timers to Azure," walks through the entire lifecycle.
Follow along with these key sections: Creating the Project: Watch how to create a new Azure Functions project and select the Timer trigger template. Notice where the CRON schedule is entered during setup. Adding C# Code: The video demonstrates adding code to the Run method. The example keeps a web app "warm," but you can simply log a message as shown in the template. Publishing to Azure: This segment shows how to create the Function App resource in Azure and publish your local project to it directly from Visual Studio.
A Real-World Consideration: Time Zones
By default, the timer trigger uses Coordinated Universal Time (UTC). If you schedule a function to run at 9:00 AM with the expression 0 0 9 * * *, it will run at 9:00 AM UTC. This can be problematic if your business logic is tied to a specific local time zone.
To address this, you must add an application setting to your Function App in Azure (or in your local.settings.json file for local testing) called WEBSITE_TIME_ZONE.
Timer trigger for Azure Functions
The official documentation explains how to handle time zones.
Read the section "NCRONTAB time zones". It explains how to set WEBSITE_TIME_ZONE for both Windows and Linux hosting plans. Setting this correctly ensures your function triggers at the expected local time. For example, to run at 10:00 AM Eastern Time, you would set WEBSITE_TIME_ZONE to Eastern Standard Time and still use the CRON expression 0 0 10 * * *.
4. Testing Your Deployed Function
After deploying, you can monitor the function's executions from the Azure portal. However, you don't have to wait for the schedule to trigger to test your logic.

You can also view the live logs to confirm that the function is being triggered automatically by the schedule you defined.
Azure Function: Creating and Deploying HTTP Triggers and Timers to Azure using Visual Studio | LSC
The same video from Learn Smart Coding also shows how to monitor your function.
Watch the section on monitoring and logs. This demonstrates how to view invocation logs in the portal, which helps you confirm that your timer is firing as expected and troubleshoot any runtime errors.
Conclusion
In this lesson, you've learned how to create functions that run on an automated schedule, a critical capability for backend development. You can now build and deploy jobs for routine tasks, data aggregation, and system maintenance.
Here are the key takeaways:
- Timer Triggers execute functions based on a schedule defined by an NCRONTAB expression.
- NCRONTAB expressions in Azure Functions have six fields, including one for seconds:
{second} {minute} {hour} {day} {month} {day-of-week}. - The
[TimerTrigger]attribute is used in your C# code to define the schedule. - The
WEBSITE_TIME_ZONEapplication setting is essential for ensuring your function runs according to a specific local time zone, rather than the default UTC. - You can test timer-triggered functions on-demand in the Azure portal without waiting for the next scheduled occurrence.
In our next lesson, we will combine our knowledge of triggers with another core Azure service. You will implement a blob-triggered Azure Function to process data from Azure Blob Storage, a powerful pattern for creating event-driven data processing pipelines.