Microsoft Certified: Azure Developer Associate (AZ-204)Develop Azure compute solutionsMedium
A company is developing an Azure Function that needs to periodically fetch data from an external API, transform it, and store it in Azure Cosmos DB. The function should run automatically every hour without requiring any explicit HTTP requests. Which trigger type is most suitable for this Azure Function?
- AHTTP Trigger
- BBlob Trigger
- CTimer Trigger
- DCosmos DB Trigger
Show answer & explanationAnswer & explanation
Correct answer: C. Timer Trigger
A Timer Trigger allows you to execute an Azure Function on a predefined schedule using a cron expression. This perfectly matches the requirement for the function to run 'automatically every hour' without any external HTTP requests, making it ideal for scheduled data processing tasks.
Why the other options are wrong
- A. An HTTP Trigger executes a function in response to an HTTP request, which is not suitable for a function that needs to run automatically on a schedule.
- B. A Blob Trigger executes a function when a new or updated blob is detected in an Azure Storage container, which is event-driven by storage changes, not time-driven.
- D. A Cosmos DB Trigger executes a function in response to changes (inserts, updates, deletes) in an Azure Cosmos DB collection, not on a schedule.
Azure Function Timer Trigger
Executes an Azure Function on a predetermined, recurring schedule using a cron expression.
- Ideal for scheduled tasks, cleanups, data processing
- Uses NCronTab expressions for defining schedules
- Can be configured to run as frequently as needed (e.g., every second, hour, day)
Memory trick: Timer Triggers run on Time, not on data or requests.