Not sure if this can be done as I'm finding conflicting answers across the net.
I have a single Azure function app with :
[Function("RetrieveMongoData")]
public void Run([TimerTrigger("0 0 * * * *")] TimerInfo myTimer)
{ .....
[Function("RetrieveMongoDataNL")]
public void Run([TimerTrigger("0 5 * * * *")] TimerInfo myTimer)
{....
each function are in their own class. When I hit F5 in VS to debug, the first function above gets hit and I can debug that function. Placing a breakpoint in the second function and it never get's hit. Can I create the triggers like this or is there a better way?
I'm doing it this way because so much of my code that gets called will be shared between the 2 triggers.
* * * * *
and */2 * * * *
expressions in my function.{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
RetrieveMongoData.cs :-
[Function("RetrieveMongoData")]
public void Run([TimerTrigger("* * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
}
RetrieveMongoDataNL.cs :-
[Function("RetrieveMongoDataNL")]
public void Run([TimerTrigger("*/2 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
}
Both the functions are being triggered successfully locally.
Azure Functions Core Tools
Core Tools Version: 4.0.6280 Commit hash: N/A +421f0144b42047aa289ce691dc6db4fc8b6143e6 (64-bit)
Function Runtime Version: 4.834.3.22875
[2025-01-06T03:50:28.958Z] Found C:\Users\****\Documents\functionApp\79326599\79326599.csproj. Using for user secrets file configuration.
[2025-01-06T03:50:31.164Z] Worker process started and initialized.
Functions:
RetrieveMongoData: timerTrigger
RetrieveMongoDataNL: timerTrigger
For detailed output, run func with --verbose flag.
[2025-01-06T03:50:36.170Z] Host lock lease acquired by instance ID '0000000000000000000000000D2022A4'.
[2025-01-06T03:51:00.050Z] Executing 'Functions.RetrieveMongoData' (Reason='Timer fired at 2025-01-06T09:21:00.0275508+05:30', Id=f923c3b2-9537-4ce4-b0da-74473ad1d4a7)
[2025-01-06T03:51:00.212Z] Next timer schedule at: 06-01-2025 09:21:00
[2025-01-06T03:51:00.212Z] C# Timer trigger function executed at: 06-01-2025 09:21:00
[2025-01-06T03:51:00.254Z] Executed 'Functions.RetrieveMongoData' (Succeeded, Id=f923c3b2-9537-4ce4-b0da-74473ad1d4a7, Duration=207ms)
[2025-01-06T03:52:00.000Z] Executing 'Functions.RetrieveMongoData' (Reason='Timer fired at 2025-01-06T09:21:59.9996713+05:30', Id=34bf0d9d-65cf-4e9f-8770-07b56366eb37)
[2025-01-06T03:52:00.015Z] Executing 'Functions.RetrieveMongoDataNL' (Reason='Timer fired at 2025-01-06T09:22:00.0152879+05:30', Id=9266d492-8c96-4b9b-b2a0-8337a7b2a4d1)
[2025-01-06T03:52:00.100Z] C# Timer trigger function executed at: 06-01-2025 09:22:00
[2025-01-06T03:52:00.103Z] Next timer schedule at: 06-01-2025 09:22:00
[2025-01-06T03:52:00.107Z] C# Timer trigger function executed at: 06-01-2025 09:22:00
[2025-01-06T03:52:00.108Z] Next timer schedule at: 06-01-2025 09:22:00
[2025-01-06T03:52:00.109Z] Executed 'Functions.RetrieveMongoDataNL' (Succeeded, Id=9266d492-8c96-4b9b-b2a0-8337a7b2a4d1, Duration=94ms)
[2025-01-06T03:52:00.108Z] Executed 'Functions.RetrieveMongoData' (Succeeded, Id=34bf0d9d-65cf-4e9f-8770-07b56366eb37, Duration=109ms)
Then, I have deployed these function to an App service plan function app and able to get expected response.