Software Architect / Microsoft MVP (AI) and Technical Author

Azure, Azure Functions, C#, General Development, Productivity

How To: Manually Running Azure Functions that Use Timer Triggers

I have an Azure Function that runs using a Timer Trigger.

This function invokes a service class that performs some period automated tasks for the free journal and mood tracking micro-SaaS I recently shipped.

I was testing it using a separate HTTP Trigger method but for quick tests wanted a way that didn’t involve opening Postman.

You can see the function here:

//runs every hour
public static void GenerateFromTimer([TimerTrigger("0 0 * * * *"
                  #if DEBUG
                  , RunOnStartup = true
)] TimerInfo myTimer, ILogger log, ExecutionContext context)
  if (myTimer.IsPastDue)
      log.LogInformation("Timer is running late!");

  var config = new ConfigurationBuilder()
                  .AddJsonFile("appsettings.json", optional: false)

  var cfgValues = config.GetSection("values");

  log.LogInformation("C# Timer Trigger function processed a request.");

  TextAnalyticsService analyticsService =
      new TextAnalyticsService(cfgValues["TextAnalyticsEndpoint"],   cfgValues["TextAnalyticsAPIKey"]);

// invoke analytics

log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");


The cron expression 0 0 * * * * invokes the function every hour.


The following command/parameter runs the function on startup or when running in debug mode / via Visual Studio:

, RunOnStartup = true


Not the prettiest syntax but helpful if you just want it to run when your debugger launches.

Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.

Leave a Reply