Search code examples
azureazure-functionsazureportalazure-functions-isolated

Testing manually a Time Triggered Function App in the Azure Portal fails


I am having issues running a Time Triggered Function App in the Azure Portal, these are the replication steps:

  1. Function App Deployed to the Azure Portal,
  2. Click on the Time Triggered Function I want to test
  3. Click on Code + Test
  4. Click on Test/Run
  5. In Input, Select _master (Host Key)
  6. Click on Run

Result: in the output window it says "404 not found"

Does anyone have any ideas of why this is happening?

The function does not trigger automatically or by the time scheduled, but it seems to be deployed correctly which is very confusing.

I should also say that none of the other options offered in the dropdown work, and they all give me different errors:

  • default (Function Key) results in "401 Unauthorized"
  • default (Host Key) results in "403 Forbidden"
  • microsoftgraphconfiguration results in "403 Forbidden"

Function code:

[Function("DepartmentFeed")]
public async Task Run([TimerTrigger("%ScheduleTriggerTime%")]
    TimerInfo timer, FunctionContext context)
{
  var logger = context.GetLogger(nameof(DepartmentFeed));
    var graphService = new GraphService(logger);
    Instant instant = SystemClock.Instance.GetCurrentInstant();
    Stopwatch stopWatch = new Stopwatch();
    stopWatch.Start();
    logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    try
    {            
        var users = await graphService.ExtractDepartmentFeedFromEntraIdAsync();
        long azureElapsed = stopWatch.ElapsedMilliseconds;
        logger.LogInformation(
            $"Retrieved {users.Count} from AzureAD.  That took {azureElapsed / 1000} seconds @ {DateTime.Now}");
       
    }
    catch (Exception ex)
    {
        logger.LogError(ex, ex.Message);
    }
}

host.json:

{   "version": "2.0",   "functions": ["DepartmentFeed"],   "Xfunctions": [
"DepartmentFeed"],   "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": "Debug"
},
"console": {
  "isEnabled": true
},
"applicationInsights": {
  "samplingSettings": {
    "isEnabled": true,
    "maxTelemetryItemsPerSecond": 20,
    "excludedTypes": "Request"
  }
}   } }

Via Postman, I get a 404 error as well.

enter image description here

Many thanks in advance!

enter image description here

enter image description here

enter image description here


Solution

  • The function does not trigger automatically or by the time scheduled, but it seems to be deployed correctly which is very confusing.

    • It looks like the function app expects the CRON expression in six field format, so update the value of ScheduleTriggerTime to 0 * * * * * because it depends on the function app's operating system. You can also refer to this MS Doc for the same.
    • I also have got 404 error while invoking the function in function app then I made below changes.

    enter image description here

    • It is recommended to use admin key while invoking non Http triggers.
    • I used admin key from the dropdown and got 202 Accepted response code.

    enter image description here

    • I am also getting expected response using postman.

    enter image description here