title | description | ms.assetid | ms.topic | ms.date | ms.custom |
---|---|---|---|---|---|
Create a function in Azure that runs on a schedule |
Learn how to use the Azure portal to create a function that runs based on a schedule that you define. |
ba50ee47-58e0-4972-b67b-828f2dc48701 |
how-to |
04/16/2020 |
mvc, cc996988-fb4f-47 |
Learn how to use the Azure portal to create a function that runs serverless on Azure based on a schedule that you define.
To complete this tutorial:
- If you don't have an Azure subscription, create a free account before you begin.
[!INCLUDE Create function app Azure portal]
Your new function app is ready to use. Next, you'll create a function in the new function app.
:::image type="content" source="./media/functions-create-scheduled-function/function-app-create-success.png" alt-text="Function app successfully created." border="true":::
-
In your function app, select Functions, and then select + Add
:::image type="content" source="./media/functions-create-scheduled-function/function-add-function.png" alt-text="Add a function in the Azure portal." border="true":::
-
Select the Timer trigger template.
:::image type="content" source="./media/functions-create-scheduled-function/function-select-timer-trigger.png" alt-text="Select the timer trigger in the Azure portal." border="true":::
-
Configure the new trigger with the settings as specified in the table below the image, and then select Create Function.
:::image type="content" source="./media/functions-create-scheduled-function/function-configure-timer-trigger.png" alt-text="Screenshot shows the New Function page with the Timer Trigger template selected." border="true":::
Setting Suggested value Description Name Default Defines the name of your timer triggered function. Schedule 0 */1 * * * * A six field CRON expression that schedules your function to run every minute.
-
In your function, select Code + Test and expand the logs.
:::image type="content" source="./media/functions-create-scheduled-function/function-test-timer-trigger.png" alt-text="Test the timer trigger in the Azure portal." border="true":::
-
Verify execution by viewing the information written to the logs.
:::image type="content" source="./media/functions-create-scheduled-function/function-view-timer-logs.png" alt-text="View the timer trigger in the Azure portal." border="true":::
Now, you change the function's schedule so that it runs once every hour instead of every minute.
-
In your function, select Integration. Here, you define input and output bindings for your function and also set the schedule.
-
Select Timer (myTimer).
:::image type="content" source="./media/functions-create-scheduled-function/function-update-timer-schedule.png" alt-text="Update the timer schedule in the Azure portal." border="true":::
-
Update the Schedule value to
0 0 */1 * * *
, and then select Save.:::image type="content" source="./media/functions-create-scheduled-function/function-edit-timer-schedule.png" alt-text="Update function timer schedule in the Azure portal." border="true":::
You now have a function that runs once every hour, on the hour.
[!INCLUDE Next steps note]
You've created a function that runs based on a schedule. For more information about timer triggers, see Schedule code execution with Azure Functions.
[!INCLUDE Next steps note]