|
1 | 1 | ---
|
2 |
| -title: Create an event processing function | Microsoft Docs |
3 |
| -description: Use Azure Functions create a C# function that runs based on an event timer. |
4 |
| -services: functions |
5 |
| -documentationcenter: na |
6 |
| -author: ggailey777 |
7 |
| -manager: erikre |
8 |
| -editor: '' |
9 |
| -tags: '' |
10 | 2 |
|
11 | 3 | ms.assetid: 84bd0373-65e2-4022-bcca-2b9cd9e696f5
|
12 |
| -ms.service: functions |
13 |
| -ms.devlang: multiple |
14 |
| -ms.topic: get-started-article |
15 |
| -ms.tgt_pltfrm: multiple |
16 |
| -ms.workload: na |
17 |
| -ms.date: 09/25/2016 |
18 |
| -ms.author: glenga |
19 |
| - |
| 4 | +redirect_url: /azure/azure-functions/functions-create-scheduled-function |
| 5 | +ROBOTS: NOINDEX, NOFOLLOW |
20 | 6 | ---
|
21 |
| -# Create an event processing Azure Function |
22 |
| -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](functions-overview.md). |
23 |
| - |
24 |
| -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. |
25 |
| - |
26 |
| -## Prerequisites |
27 |
| -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](https://functions.azure.com/try) experience or [create a free Azure acccount](https://azure.microsoft.com/free/). |
28 |
| - |
29 |
| -## Create a timer-triggered function from the template |
30 |
| -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](https://azure.microsoft.com/free/). |
31 |
| - |
32 |
| -1. Go to the [Azure Functions portal](https://functions.azure.com/signin) and sign-in with your Azure account. |
33 |
| -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**. |
34 |
| -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. |
35 |
| - |
36 |
| -  |
37 |
| -4. In your new function, click the **Integrate** tab > **New Output** > **Azure Storage Queue** > **Select**. |
38 |
| - |
39 |
| -  |
40 |
| -5. In **Azure Storage Queue output**, select an existing **Storage account connection**, or create a new one, then click **Save**. |
41 |
| - |
42 |
| -  |
43 |
| -6. Back in the **Develop** tab, replace the existing C# script in the **Code** window with the following code: |
44 |
| - ```cs |
45 |
| - using System; |
46 |
| - |
47 |
| - public static void Run(TimerInfo myTimer, out string outputQueueItem, TraceWriter log) |
48 |
| - { |
49 |
| - // Add a new scheduled message to the queue. |
50 |
| - outputQueueItem = $"Ping message added to the queue at: {DateTime.Now}."; |
51 |
| - |
52 |
| - // Also write the message to the logs. |
53 |
| - log.Info(outputQueueItem); |
54 |
| - } |
55 |
| - ``` |
56 |
| - |
57 |
| - This code adds a new message to the queue with the current date and time when the function is executed. |
58 |
| -7. Click **Save** and watch the **Logs** windows for the next function execution. |
59 |
| -8. (Optional) Navigate to the storage account and verify that messages are being added to the queue. |
60 |
| -9. Go back to the **Integrate** tab and change the schedule field to `0 0 * * * *`. The function now runs once every hour. |
61 |
| - |
62 |
| -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](functions-bindings-timer.md) and the [Azure Functions triggers and bindings for Azure Storage](functions-bindings-storage.md) topics. |
63 |
| - |
64 |
| -## Next steps |
65 |
| -See these topics for more information about Azure Functions. |
66 |
| - |
67 |
| -* [Azure Functions developer reference](functions-reference.md) |
68 |
| - Programmer reference for coding functions and defining triggers and bindings. |
69 |
| -* [Testing Azure Functions](functions-test-a-function.md) |
70 |
| - Describes various tools and techniques for testing your functions. |
71 |
| -* [How to scale Azure Functions](functions-scale.md) |
72 |
| - Discusses service plans available with Azure Functions, including the Consumption hosting plan, and how to choose the right plan. |
73 |
| - |
74 |
| -[!INCLUDE [Getting Started Note](../../includes/functions-get-help.md)] |
75 | 7 |
|
0 commit comments