Create an event processing Azure Function

Azure Functions is an event-driven, compute-on-demand experience that enables you to create scheduled or triggered units of code implemented in a variety of programming languages. To learn more about Azure Functions, see the Azure Functions Overview.

This topic shows you how to create a new function in C# that executes based on an event timer to add messages to a storage queue.


A function app hosts the execution of your functions in Azure. If you don't already have an Azure account, check out the Try Functions experience or create a free Azure acccount.

Create a timer-triggered function from the template

A function app hosts the execution of your functions in Azure. Before you can create a function, you need to have an active Azure account. If you don't already have an Azure account, free accounts are available.

  1. Go to the Azure Functions portal and sign-in with your Azure account.
  2. If you have an existing function app to use, select it from Your function apps then click Open. To create a new function app, type a unique Name for your new function app or accept the generated one, select your preferred Region, then click Create + get started.
  3. In your function app, click + New Function > TimerTrigger - C# > Create. This creates a function with a default name that is run on the default schedule of once every minute.

    Create a new timer-triggered function

  4. In your new function, click the Integrate tab > New Output > Azure Storage Queue > Select.

    Create a new timer-triggered function

  5. In Azure Storage Queue output, select an existing Storage account connection, or create a new one, then click Save.

    Create a new timer-triggered function

  6. Back in the Develop tab, replace the existing C# script in the Code window with the following code:

     using System;
     public static void Run(TimerInfo myTimer, out string outputQueueItem, TraceWriter log)
         // Add a new scheduled message to the queue.
         outputQueueItem = $"Ping message added to the queue at: {DateTime.Now}.";
         // Also write the message to the logs.

    This code adds a new message to the queue with the current date and time when the function is executed.

  7. Click Save and watch the Logs windows for the next function execution.
  8. (Optional) Navigate to the storage account and verify that messages are being added to the queue.
  9. Go back to the Integrate tab and change the schedule field to 0 0 * * * *. The function now runs once every hour.

This is a very simplified example of both a timer trigger and a storage queue output binding. For more information, see both the Azure Functions timer trigger and the Azure Functions triggers and bindings for Azure Storage topics.

Next steps

See these topics for more information about Azure Functions.

Need some help?

Post questions in the Azure forums. - Visit MSDN

Tag questions with the keyword azure-functions. - Visit Stack Overflow