Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions with trigger timer don't show logs under Monitor

I'm testing my Azure Functions and facing a funny problem. I want to see if a function was running and the result. I'm opening the function and then my function called getTokenRefresh. Apparently, this function has never started.

enter image description here

After a couple of hours, I decided to open Application Insights. Surprise! All logs are there.

enter image description here

If I run a function from the portal and open again monitor and click on the Logs tab, I don't see any logs. Again I can find everything only in Application Insights.

Another interesting thing is other functions in this Azure Functions, show me all details (believe me is the same function).

enter image description here

In the code point of view, I'm using dependency injection in all functions like:

public class GetTokenRefreshTimer
{
    private ILogger _log;

    public GetTokenRefreshTimer(ILogger<GetTokenRefreshTimer> log)
    {
        _log = log;
    }

    [FunctionName("getTokenRefreshTimer")]
    public async Task Run([TimerTrigger("0 */20 * * * *")]TimerInfo myTimer)
    {
        _log.LogInformation("GetTokenRefresh starts");
    }
}
like image 869
Enrico Rossini Avatar asked Oct 24 '25 02:10

Enrico Rossini


1 Answers

The logs of azure function is fragile. So sometimes you can not see the logs, but this doesn't mean the azure function is not run.

If you want to know the function is running you need to go to the kudu of your azure function and see the logs file of your function app.(The logs in Application Insights is coming from this place.)

The logs file is in the place:

Open your brower and go to https://yourfunctionappname.scm.azurewebsites.net/DebugConsole, and then click into LogFiles/Application/Functions/Function/yourtriggername . You will find the log file in this place.

like image 144
Cindy Pau Avatar answered Oct 26 '25 00:10

Cindy Pau