I have created and deployed a group of function apps (Blob and Time triggered) and they are deployed on the Azure Portal, it all seems fine locally but I have noticed that when I look at the logs on the portal (App Insights), I can only see 2 entries and the function finishes running in few miliseconds which I find a bit estrange as locally it takes more time to complete, but I can’t find the reason for this (I have got many entries throughout the code).
Code example:
[Function("TeamLinkDepartmentFeed")]
public async Task Run([TimerTrigger("%ScheduleTriggerTime%")]
TimerInfo timer, FunctionContext context)
{
var logger = context.GetLogger(nameof(TeamLinkDepartmentFeed));
try
{
logger.LogInformation($"C# Timer trigger TeamLinkDepartmentFeed function executed at: {DateTime.Now}");
var graphService = new GraphService(logger);
Instant instant = SystemClock.Instance.GetCurrentInstant();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
var departmentListId = Environment.GetEnvironmentVariable("DepartmentListId");
var sharepointSiteId = Environment.GetEnvironmentVariable("SharepointSiteId");
List<User> users = await graphService.ExtractDepartmentFeedFromEntraIdAsync();
long azureElapsed = stopWatch.ElapsedMilliseconds;
logger.LogInformation(
$"Retrieved {users.Count} from AzureAD. That took {azureElapsed / 1000} seconds @ {DateTime.Now}");
List<Department> departments = ConvertGraphUsersToDepartments(users, instant, logger);
List<Department> departmentsWithActionSet = await graphService.SetDepartmentActionByCheckingExistingRecords(departments, departmentListId, sharepointSiteId);
await UpdateDepartmentListAsync(departmentsWithActionSet, graphService, logger, sharepointSiteId, departmentListId);
logger.LogInformation($"Department feed has been updated, That took {(azureElapsed) / 1000} seconds - total {stopWatch.ElapsedMilliseconds / 1000} seconds @ {DateTime.Now} function completed successfully");
}
catch (Exception ex)
{
logger.LogError(ex, $" Error executing function {context.FunctionDefinition} {ex.Message}");
}
Even more unusual, I can see some logging coming from the Blob storage which has not been triggered and I don’t understand why this is happening inside the logs of my time triggered functions if they are not depending on each other. This only happens when I programmatically trigger the function using Postman, please see screenshot below
can someone help please?
Here is my Host.json
{
“version”: “2.0”,
“functions”: [],
“functionTimeout”: “00:10:00”,
“healthMonitor”: {
“enabled”: false,
“healthCheckInterval”: “00:00:10”,
“healthCheckWindow”: “00:02:00”,
“healthCheckThreshold”: 6,
“counterThreshold”: 0.8
},
“logging”: {
“fileLoggingMode”: “debugOnly”,
“logLevel”: {
“default”: “Information”
},
“console”: {
“isEnabled”: true
},
“applicationInsights”: {
“samplingSettings”: {
“isEnabled”: true,
“maxTelemetryItemsPerSecond”: 20,
“excludedTypes”: “Request”
}
}
}
}
Many thanks in advance!