none
Local debug of azure functions acts differently for HTTP vs Timer trigger RRS feed

  • Question

  • I am locally debugging a bunch of Azure functions.  The basic idea in my architecture is that some main Orchestrator queues a bunch of Azure queue elements, and another function is waiting on queue elements to process.

    I am converting the orchestrator from being kicked off by a timer to being kicked off by a Http trigger.

    The old timer trigger used this function signature:

            public static void Run([TimerTrigger("0 0 5 * * *", RunOnStartup = true)]TimerInfo myTimer, TraceWriter log)
    

    The new Http trigger uses this signature

            public static async Task<HttpResponseMessage> Run([HttpTrigger(WebHookType = "genericJson")]HttpRequestMessage req, TraceWriter log)
    

    When I debug the timer trigger locally, the timer trigger queues the jobs, and the orchestrator exits with success.  I then see the output of the queued jobs until they finish,

    When I kick the Http trigger off from POSTMAN, it runs, and queues the jobs, and exits.  BUT for some reason, I only see the output from the jobs that happen to run while the http trigger is active.  The output stops when the Http trigger job exits.

    If I exit my local function app, and re-enter, I again get the queue functions output showing up on my local console.

    For some reason, the operation is different depending on which kind of trigger I use, and I'm not sure why that is, since in both cases, the initial trigger function does its job, and then exits.

    I've been able to get underlying queued jobs from HTTP triggers to continue to run after the trigger before.  Has something changed?  Is there a setting that should control this?

    -thanks


    -- me --

    Tuesday, March 13, 2018 8:54 PM

Answers

  • I can't repro. Do you have steps you can take from a brand new function app that result in this behavior? 

    Here's what I did:

    1. VS 2017 -> File -> New -> Cloud -> Function App

    2. Pick V1, HttpTrigger

    3. Update the function code to write to some queues and add two queue triggered functions. See this gist:

    https://gist.github.com/paulbatum/761f5ad72e896360533926ccffa2c918

    4. Start the storage emulator

    5. Hit F5

    6. Open fiddler and send a request to:

    http://localhost:7071/api/Orchestrator

    7. Get the following output:

    Http Functions:
    
            Orchestrator: http://localhost:7071/api/Orchestrator
    
    Debugger listening on [::]:5858
    [3/14/2018 1:00:23 AM] Executing HTTP request: {
    [3/14/2018 1:00:23 AM]   "requestId": null,
    [3/14/2018 1:00:23 AM]   "method": "POST",
    [3/14/2018 1:00:23 AM]   "uri": "/api/Orchestrator"
    [3/14/2018 1:00:23 AM] }
    [3/14/2018 1:00:23 AM] Function started (Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:23 AM] Executing 'Orchestrator' (Reason='This function was programmatically called via the host APIs.', Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:23 AM] Sleeping...
    [3/14/2018 1:00:26 AM] Function started (Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:26 AM] Function completed (Success, Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c, Duration=3318ms)
    [3/14/2018 1:00:26 AM] Executing 'QueueFunction1' (Reason='New queue message detected on 'queue1'.', Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:26 AM] Executed 'Orchestrator' (Succeeded, Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:26 AM] Function started (Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)
    [3/14/2018 1:00:26 AM] Executed HTTP request: {
    [3/14/2018 1:00:26 AM]   "requestId": "078baa92-b1bb-4321-8189-760e294b65a9",
    [3/14/2018 1:00:26 AM]   "method": "POST",
    [3/14/2018 1:00:26 AM]   "uri": "/api/Orchestrator",
    [3/14/2018 1:00:26 AM] Executing 'QueueFunction2' (Reason='New queue message detected on 'queue2'.', Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)
    [3/14/2018 1:00:26 AM]   "authorizationLevel": "Anonymous"
    [3/14/2018 1:00:26 AM] }
    [3/14/2018 1:00:26 AM] Response details: {
    [3/14/2018 1:00:26 AM]   "requestId": "078baa92-b1bb-4321-8189-760e294b65a9",
    [3/14/2018 1:00:26 AM]   "status": "OK"
    [3/14/2018 1:00:26 AM] }
    [3/14/2018 1:00:31 AM] C# Queue trigger function processed: test1
    [3/14/2018 1:00:31 AM] Function completed (Success, Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b, Duration=5053ms)
    [3/14/2018 1:00:31 AM] Executed 'QueueFunction1' (Succeeded, Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:31 AM] C# Queue trigger function processed: test2
    [3/14/2018 1:00:31 AM] Function completed (Success, Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d, Duration=5030ms)
    [3/14/2018 1:00:31 AM] Executed 'QueueFunction2' (Succeeded, Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)


    • Edited by Paul Batum Wednesday, March 14, 2018 1:04 AM
    • Marked as answer by Chief Scientist Wednesday, March 14, 2018 1:46 AM
    Wednesday, March 14, 2018 1:03 AM

All replies

  • Is this a Service Bus Queue you're working with?

    And, are you saying only the Trace output stops or processing stops completely?

    Wednesday, March 14, 2018 12:59 AM
  • I can't repro. Do you have steps you can take from a brand new function app that result in this behavior? 

    Here's what I did:

    1. VS 2017 -> File -> New -> Cloud -> Function App

    2. Pick V1, HttpTrigger

    3. Update the function code to write to some queues and add two queue triggered functions. See this gist:

    https://gist.github.com/paulbatum/761f5ad72e896360533926ccffa2c918

    4. Start the storage emulator

    5. Hit F5

    6. Open fiddler and send a request to:

    http://localhost:7071/api/Orchestrator

    7. Get the following output:

    Http Functions:
    
            Orchestrator: http://localhost:7071/api/Orchestrator
    
    Debugger listening on [::]:5858
    [3/14/2018 1:00:23 AM] Executing HTTP request: {
    [3/14/2018 1:00:23 AM]   "requestId": null,
    [3/14/2018 1:00:23 AM]   "method": "POST",
    [3/14/2018 1:00:23 AM]   "uri": "/api/Orchestrator"
    [3/14/2018 1:00:23 AM] }
    [3/14/2018 1:00:23 AM] Function started (Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:23 AM] Executing 'Orchestrator' (Reason='This function was programmatically called via the host APIs.', Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:23 AM] Sleeping...
    [3/14/2018 1:00:26 AM] Function started (Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:26 AM] Function completed (Success, Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c, Duration=3318ms)
    [3/14/2018 1:00:26 AM] Executing 'QueueFunction1' (Reason='New queue message detected on 'queue1'.', Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:26 AM] Executed 'Orchestrator' (Succeeded, Id=88b944f7-84f8-4c53-b1d7-5a742e25cc5c)
    [3/14/2018 1:00:26 AM] Function started (Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)
    [3/14/2018 1:00:26 AM] Executed HTTP request: {
    [3/14/2018 1:00:26 AM]   "requestId": "078baa92-b1bb-4321-8189-760e294b65a9",
    [3/14/2018 1:00:26 AM]   "method": "POST",
    [3/14/2018 1:00:26 AM]   "uri": "/api/Orchestrator",
    [3/14/2018 1:00:26 AM] Executing 'QueueFunction2' (Reason='New queue message detected on 'queue2'.', Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)
    [3/14/2018 1:00:26 AM]   "authorizationLevel": "Anonymous"
    [3/14/2018 1:00:26 AM] }
    [3/14/2018 1:00:26 AM] Response details: {
    [3/14/2018 1:00:26 AM]   "requestId": "078baa92-b1bb-4321-8189-760e294b65a9",
    [3/14/2018 1:00:26 AM]   "status": "OK"
    [3/14/2018 1:00:26 AM] }
    [3/14/2018 1:00:31 AM] C# Queue trigger function processed: test1
    [3/14/2018 1:00:31 AM] Function completed (Success, Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b, Duration=5053ms)
    [3/14/2018 1:00:31 AM] Executed 'QueueFunction1' (Succeeded, Id=be1f1643-1bc8-4d8e-8949-e33af9cc668b)
    [3/14/2018 1:00:31 AM] C# Queue trigger function processed: test2
    [3/14/2018 1:00:31 AM] Function completed (Success, Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d, Duration=5030ms)
    [3/14/2018 1:00:31 AM] Executed 'QueueFunction2' (Succeeded, Id=e4b54b2a-f2ec-425a-9fce-629f7a6e2a8d)


    • Edited by Paul Batum Wednesday, March 14, 2018 1:04 AM
    • Marked as answer by Chief Scientist Wednesday, March 14, 2018 1:46 AM
    Wednesday, March 14, 2018 1:03 AM
  • @Paul and @Johns-305:

    Thanks for the help.

    @Johns-305, yes these were Storage Queues not service bus queues.

    Looks like @Paul has proven this isn't a normal situation, and we may have just seen a one-time glitch.  Something strange with local Azure CLI, maybe?  No big deal, and If I see it happen a lot more, I'll be sure to check back.

    @Paul the only difference is that i'm local, but using Azure services.  Not using Storage Emulator, but that probably doesn't make any difference.

    As I said, this only happened once and I was just curious whether this is normal operation.  It doesn't appear that it is.

    Let's just close this one and save our time for more important work.

    -thanks
    -e


    -- me --

    Wednesday, March 14, 2018 1:45 AM