Have created a multiproject solution in C# .NET6 in which there is a Function project. Function project contains a timer triggered function:
[FunctionName("Function1")]
public async Task Run([TimerTrigger("0 0/1 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
Am using Visual studio 2022 so have right clicked the function project in my solution and choosen publish. The publishing works and the app is uploaded to Azure and creates a new Function in Azure portal that is up and running.
In Application Insight on Azure portal I can see the following message in Transaction Search: Host Status: { "id": "functionappjohantest", "state": "Running", "version": "4.30.0.22097",..................
However the timer trigger that is set to once a minute is never triggered as there is no new input in Application Insight.
What is wrong here?
UPDATE - After lots of trying and mixed results I deleted my whole resource group and created a new one, also created new function solutions (two .NET6, one isolated and one not, one .NET8 isolated). Created new application insight group etc that came with publishing functions to Azure.
Without making any own changes there is a difference with profile settings between .NET8 and .NET6, both seems to work fine though.
I see both the isolated and not isolated functions running with invocation trace in each function but when looking in application insight transaction search I can see all functions executing: But can't see the log of the isolated processes who use this type of log setup in visual studio:
So in conclusion, I have no idea what was wrong before and still don't understand why logging isn't showing up in transaction search for the application insight group but besides that it seems work.
Thanks, Adam Vincent for the insights.
Function code:
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp2
{
public class Function1
{
[FunctionName("Function1")]
public void Run([TimerTrigger("0 0/1 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
The above function executed successfully in local. check below:
After, I published the function into portal successfully.
The function runs successfully in portal as well. check below:
Output: