| title | Run scheduled tasks using Azure Functions |
|---|---|
| description | Learn how to use the Azure Developer CLI (azd) to create resources and deploy a scheduled task project to a Flex Consumption plan on Azure. |
| ms.date | 12/01/2025 |
| ms.topic | quickstart |
| ai-usage | ai-assisted |
| zone_pivot_groups | programming-languages-set-functions |
In this article, you use the Azure Developer CLI (azd) to create a Timer trigger function to run a scheduled task in Azure Functions. After verifying the code locally, you deploy it to a new serverless function app you create running in a Flex Consumption plan in Azure Functions.
The project source uses azd to create the function app and related resources and to deploy your code to Azure. This deployment follows current best practices for secure and scalable Azure Functions deployments.
By default, the Flex Consumption plan follows a pay-for-what-you-use billing model, which means you can complete this article and only incur a small cost of a few USD cents or less in your Azure account. ::: zone pivot="programming-language-java,programming-language-javascript,programming-language-powershell"
Important
While running scheduled tasks is supported for all languages, this quickstart scenario currently only has examples for C#, Python, and TypeScript. To complete this quickstart, select one of these supported languages at the top of the article.
::: zone-end
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
::: zone-end
::: zone pivot="programming-language-csharp"
- .NET 8 SDK ::: zone-end
::: zone pivot="programming-language-typescript"
-
Node.js 22 or above
::: zone-end
::: zone pivot="programming-language-python" -
Python 3.11 or above
-
Azurite storage emulator ::: zone-end
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript" -
An Azure account with an active subscription. Create an account for free.
Use the azd init command to create a local Azure Functions code project from a template.
::: zone-end
::: zone pivot="programming-language-csharp"
-
In your local terminal or command prompt, run this
azd initcommand in an empty folder:azd init --template functions-quickstart-dotnet-azd-timer -e scheduled-dotnetThis command pulls the project files from the template repository and initializes the project in the current folder. The
-eflag sets a name for the current environment. Inazd, the environment maintains a unique deployment context for your app, and you can define more than one. The environment name is also used in the name of the resource group you create in Azure. -
Run this command to navigate to the app folder:
cd src -
Create a file named local.settings.json in the
srcfolder that contains this JSON data:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", "TIMER_SCHEDULE": "*/30 * * * * *" } }This file is required when running locally. ::: zone-end
::: zone pivot="programming-language-typescript" -
In your local terminal or command prompt, run this
azd initcommand in an empty folder:azd init --template functions-quickstart-typescript-azd-timer -e scheduled-tsThis command pulls the project files from the template repository and initializes the project in the current folder. The
-eflag sets a name for the current environment. Inazd, the environment maintains a unique deployment context for your app, and you can define more than one. The environment name is also used in the name of the resource group you create in Azure. -
Create a file named local.settings.json in the
srcfolder that contains this JSON data:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "node", "TIMER_SCHEDULE": "*/30 * * * * *" } }This file is required when running locally. ::: zone-end
::: zone pivot="programming-language-python" -
In your local terminal or command prompt, run this
azd initcommand in an empty folder:azd init --template functions-quickstart-python-azd-timer -e scheduled-pyThis command pulls the project files from the template repository and initializes the project in the current folder. The
-eflag sets a name for the current environment. Inazd, the environment maintains a unique deployment context for your app, and you can define more than one. The environment name is also used in the name of the resource group you create in Azure. -
Create a file named local.settings.json in the
srcfolder that contains this JSON data:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "python", "TIMER_SCHEDULE": "*/30 * * * * *" } }This file is required when running locally.
In the root folder, run these commands to create and activate a virtual environment named .venv:
python3 -m venv .venv
source .venv/bin/activateIf Python doesn't install the venv package on your Linux distribution, run the following command:
sudo apt-get install python3-venvpy -m venv .venv
source .venv/scripts/activatepy -m venv .venv
.venv\scripts\activate::: zone-end ::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
::: zone-end
::: zone pivot="programming-language-csharp,programming-language-python"
-
Run this command from your app folder in a terminal or command prompt:
func start
::: zone-end
::: zone pivot="programming-language-typescript"
-
Run this command from your app folder in a terminal or command prompt:
npm install npm start
::: zone-end
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript" 2. When the Functions host starts in your local project folder, it writes information about your Timer triggered function to the terminal output. You should see your Timer triggered function execute based on the schedule defined in your code.
The default schedule is `*/30 * * * * *`, which runs every 30 seconds.
- When you're done, press Ctrl+C in the terminal window to stop the
func.exehost process. ::: zone-end ::: zone pivot="programming-language-python" - Run
deactivateto shut down the virtual environment. ::: zone-end ::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
You can review the code that defines the Timer trigger function:
::: zone-end
::: zone pivot="programming-language-csharp"
:::code language="csharp" source="~/functions-azd-timer-dotnet/src/timerFunction.cs" range="1-6,10-18,29-43" :::
You can review the complete template project here.
::: zone-end
::: zone pivot="programming-language-typescript"
:::code language="typescript" source="~/functions-azd-timer-typescript/src/src/functions/timerFunction.ts" range="1-2,12-24" :::
You can review the complete template project here.
::: zone-end
::: zone pivot="programming-language-python"
:::code language="python" source="~/functions-azd-timer-python/src/function_app.py" range="1-13,25-30" :::
You can review the complete template project here.
::: zone-end
::: zone pivot="programming-language-csharp,programming-language-python,programming-language-typescript"
After you verify your function locally, it's time to publish it to Azure.
This project is configured to use the azd up command to deploy your code to a new function app in a Flex Consumption plan in Azure.
Tip
This project includes a set of Bicep files that azd uses to create a secure deployment to a Flex consumption plan that follows best practices.
-
Run this command to have
azdcreate the required Azure resources in Azure and deploy your code project to the new function app:azd upThe root folder contains the
azure.yamldefinition file required byazd.If you're not already signed in, you're asked to authenticate with your Azure account.
-
When prompted, provide these required deployment parameters:
Parameter Description Azure subscription Subscription in which your resources are created. Azure location Azure region in which to create the resource group that contains the new Azure resources. Only regions that currently support the Flex Consumption plan are shown. The
azd upcommand uses your response to these prompts with the Bicep configuration files to complete these deployment tasks:-
Create and configure these required Azure resources (equivalent to
azd provision):- Flex Consumption plan and function app
- Azure Storage (required) and Application Insights (recommended)
- Access policies and roles for your account
- Service-to-service connections using managed identities (instead of stored connection strings)
- Virtual network to securely run both the function app and the other Azure resources
-
Package and deploy your code to the deployment container (equivalent to
azd deploy). The app is then started and runs in the deployed package.
After the command completes successfully, you see links to the resources you created.
-
After deployment completes, your Timer trigger function automatically starts running in Azure based on its schedule.
-
In the Azure portal, go to your new function app.
-
Select Log stream from the left menu to monitor your function executions in real-time.
-
You should see log entries that show your Timer trigger function executing according to its schedule.
[!INCLUDE functions-scenario-redeploy-cleanup] ::: zone-end