locked
run app if statusCode is not equal 200 RRS feed

  • Question

  • Hi,

    I'm using ftp trigger ( when a file is added or modified ).

    My app moves the file from ftp to storage container as blob and sends event to event hub with some custom data.

    Everything works just fine when trigger can access ftp.

    So... Is there a way to run the app even if trigger executes with status code other than 200, like 404

    I've already added a condition for that after the trigger - I'd would just send a fail event to event hub

    The problem is that If the status code is not 200 the app stops at trigger and doesn't reach the contition step

    Thanks for any help :)


    • Edited by michszau Friday, February 23, 2018 5:29 PM
    Friday, February 23, 2018 5:28 PM

Answers

  • No, this is a common behavior across many Triggers.  If it doesn't 'work' the Logic App just isn't triggered.

    If you need to be able to handle any non-normal circumstance, including the file merely not being there which isn't a true error, you'll have to Trigger you Logic App with an Occurrence Trigger, then poll the FTP site.

    If the FTP Connector fails or returns no files, you can then take the appropriate actions.

    • Proposed as answer by WSilveiraNZ [MVP]MVP Friday, February 23, 2018 8:54 PM
    • Marked as answer by michszau Monday, February 26, 2018 9:29 AM
    Friday, February 23, 2018 6:26 PM
  • That is the intended behavior of the Trigger you are using i.e to fire only and only if the file is present at the monitored location.

    If the file is not there the trigger wont just fire up, it will just skip.

    As Johns-305 say, if you want more freedom around with the way status codes are to be handled mainly 200 for file found and 404 for file not found, you will have to use the actions that come with the FTP connector probably using the List Files in Folder and Get File Content in that order ( remember these are two separate actions and will be billed accordingly) and you will have to set up a schedule trigger for this logic app to poll periodically (Analyze the number of runs and the action executed in each run and evaluate if that approach is worth the logic that you want to implement based upon the condition on status code?)



    Mandar Dharmadhikari

    • Proposed as answer by WSilveiraNZ [MVP]MVP Friday, February 23, 2018 8:59 PM
    • Marked as answer by michszau Monday, February 26, 2018 9:29 AM
    Friday, February 23, 2018 7:49 PM

All replies

  • No, this is a common behavior across many Triggers.  If it doesn't 'work' the Logic App just isn't triggered.

    If you need to be able to handle any non-normal circumstance, including the file merely not being there which isn't a true error, you'll have to Trigger you Logic App with an Occurrence Trigger, then poll the FTP site.

    If the FTP Connector fails or returns no files, you can then take the appropriate actions.

    • Proposed as answer by WSilveiraNZ [MVP]MVP Friday, February 23, 2018 8:54 PM
    • Marked as answer by michszau Monday, February 26, 2018 9:29 AM
    Friday, February 23, 2018 6:26 PM
  • That is the intended behavior of the Trigger you are using i.e to fire only and only if the file is present at the monitored location.

    If the file is not there the trigger wont just fire up, it will just skip.

    As Johns-305 say, if you want more freedom around with the way status codes are to be handled mainly 200 for file found and 404 for file not found, you will have to use the actions that come with the FTP connector probably using the List Files in Folder and Get File Content in that order ( remember these are two separate actions and will be billed accordingly) and you will have to set up a schedule trigger for this logic app to poll periodically (Analyze the number of runs and the action executed in each run and evaluate if that approach is worth the logic that you want to implement based upon the condition on status code?)



    Mandar Dharmadhikari

    • Proposed as answer by WSilveiraNZ [MVP]MVP Friday, February 23, 2018 8:59 PM
    • Marked as answer by michszau Monday, February 26, 2018 9:29 AM
    Friday, February 23, 2018 7:49 PM
  • This is the exact scenario of where you would want to add an Azure Function into a logic app. The Logic app is hitting an area where you simply need more functionality and with a Azure Function you write and control the logic to do what you want with the different status codes through the use of code logic. I would highly recommend this path of integration to accomplish the task you have at hand. 

    Here is a great blog walking you through the concept:

    https://blogs.msdn.microsoft.com/mvpawardprogram/2016/08/16/extending-azure-logic-apps-using-azure-functions/

    Hope that helps!

    ~Theo

    Friday, February 23, 2018 8:18 PM
  • Hi Theo,

    I don't think that this is a case for functions in this particularly instance (don't get me wrong, I am a big fun of Functions + Logic Apps = Better Together - have the t-shirt to prove and everything). But in this case is a more a matter of selecting the appropriate trigger. The solution John and Mandar propose would be my preferred solution, as you can wake up the logic app on a regular basis, interrogate the FTP server for files, and act accordingly.

    My two cents, Wagner.

    Friday, February 23, 2018 9:00 PM
  • I understand your thinking however, in this case they are wanting to take a different approach depending on the status codes returned and fork out work logic with each code path. Logic Apps were designed with a "if this then that" simplicity form of flow and a "no developer required" methodology; This breaks those rules. This is the perfect place to integrate in the functionality to a Azure Function to architect the more complex action.

    The bank has my two cents...

    ~Theo

     

    Friday, February 23, 2018 11:42 PM
  • Thanks for your answers, using a scheduled trigger seems to resolve my problem.
    Monday, February 26, 2018 9:30 AM