1

I have created an azure function and its timeout is set to 10mins in hosts.json but when I am triggering it through ADF V2 azure function activity then activity is getting terminated after 4mins 7sec, Can any one guide me what is happening at the backend and why I am getting this behavior? Thanks.

Update: If i run my azure function through ADF or from postman it gives me this error after 4min 7sec:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>502 - Web server received an invalid response while acting as a gateway or proxy server.</title>
    <style type="text/css">
        < !-- body {
            margin: 0;
            font-size: .7em;
            font-family: Verdana, Arial, Helvetica, sans-serif;
            background: #EEEEEE;
        }

        fieldset {
            padding: 0 15px 10px 15px;
        }

        h1 {
            font-size: 2.4em;
            margin: 0;
            color: #FFF;
        }

        h2 {
            font-size: 1.7em;
            margin: 0;
            color: #CC0000;
        }

        h3 {
            font-size: 1.2em;
            margin: 10px 0 0 0;
            color: #000000;
        }

        #header {
            width: 96%;
            margin: 0 0 0 0;
            padding: 6px 2% 6px 2%;
            font-family: "trebuchet MS", Verdana, sans-serif;
            color: #FFF;
            background-color: #555555;
        }

        #content {
            margin: 0 0 0 2%;
            position: relative;
        }

        .content-container {
            background: #FFF;
            width: 96%;
            margin-top: 8px;
            padding: 10px;
            position: relative;
        }

        -->
    </style>
</head>

<body>
    <div id="header">
        <h1>Server Error</h1>
    </div>
    <div id="content">
        <div class="content-container">
            <fieldset>
                <h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
                <h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web
                    server (while acting as a gateway or proxy) contacted the upstream content server, it received an
                    invalid response from the content server.</h3>
            </fieldset>
        </div>
    </div>
</body>

</html>

And if I go to App insights of function App it shows me timeout of 10mins which I think is correct because I am using consumption plan so I know that. But at 4min and 7sec the 502 response which is sent to the client i am not familier with issue. Please guide.

Bilal Shafqat
  • 689
  • 2
  • 14
  • 26
  • 1
    Hi Bilal, you can go to your function to see the log by yourself first. If still can't find the cause, please provide more details. – Hury Shen Feb 25 '20 at 05:15
  • @HuryShen, Thanks for replying. I am updating my question with further details. – Bilal Shafqat Feb 25 '20 at 05:42
  • 1
    May I know if this error happen every time ? Or just happen occasionally ? – Hury Shen Feb 25 '20 at 06:11
  • This is happening everytime. Let me clear again, the client either it is ADF or Postman it is returned this error "502 - Web server received an invalid response while acting as a gateway or proxy server." in 4min 7sec. While my function app continues to run as expected. And terminates after 10mins. – Bilal Shafqat Feb 25 '20 at 06:59

2 Answers2

1

As your function can continue to run as expected even though the 502 error shows, so I think it has nothing to do with your azure function.

As far as I know, azure function activity just allows 230 seconds for the request in data factory. You can refer to this document. enter image description here

If you want to request it by postman, you can set the "request time out" in the "settings" of your postman. Please refer to this document.

enter image description here

enter image description here

Hope it helps~

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • hmm, I know about that timeout which is 230secs but in my case either in ADF or in postman (with Request timeout in ms set to 0) I am getting this 502 error. – Bilal Shafqat Feb 25 '20 at 08:03
  • Hi @BilalShafqat, could you please remove all of the code in your function and replace it with "Thread.Sleep(250000);". And then test it in postman, check if it will response 502 error when it comes 4min 7s. – Hury Shen Feb 26 '20 at 01:48
  • Yup, you were right. I have used durable functions to achieve this use case due to limitation of 230 seconds. Thanks – Bilal Shafqat Mar 07 '20 at 13:29
1

Maybe just me, but if true that you are limited to 230 seconds then this is CRAZY. I can definitely run functions for longer than that. In consumption plan up to 10 minutes, in premium plan you can have 60 minutes run time. See here. If the answer is to use Durable function, then you might as well just implement your workflow in there and forget about ADF completely. Azure Function ADF Activity tool-tip states that default timeout is 12 hours. Something doesn't smell right.

zakkra
  • 11
  • 1