locked
Functions app 502 error RRS feed

  • Question

  • I have a simple web app running on localhost that's calling an Azure Function (JavaScript). The function's been working great and returning some arbitrary text data to my web application.

    As soon as I update the function to make a call to a third party API (via HTTP), the web app gets a 502 error and nothing's logged by my function (via context.log), so I can't see how far it gets during processing. 

    It feels like my function isn't even running since nothing's logged. Is the function simply not running anymore since I'm trying to make an outbound call to a REST API?

    Wednesday, April 25, 2018 11:56 AM

Answers

  • Where are you looking at your logs?

    If you're looking in the portal, it's possible that you're getting a host-level log error that's not showing there. You can also go to {sitename}.scm.azurewebsites.net, and go to Debug console, then navigate to LogFiles -> Application -> Functions to see additional logs.


    Brett Samblanet -- Azure Functions

    • Marked as answer by johnwargo Friday, April 27, 2018 10:00 AM
    Thursday, April 26, 2018 6:38 PM

All replies

  • Do I need to whitelist my external endpoint perhaps?
    Wednesday, April 25, 2018 12:09 PM
  • Where are you looking at your logs?

    If you're looking in the portal, it's possible that you're getting a host-level log error that's not showing there. You can also go to {sitename}.scm.azurewebsites.net, and go to Debug console, then navigate to LogFiles -> Application -> Functions to see additional logs.


    Brett Samblanet -- Azure Functions

    • Marked as answer by johnwargo Friday, April 27, 2018 10:00 AM
    Thursday, April 26, 2018 6:38 PM
  • Brett, thanks so much for that, that pointed me to the error. 
    Friday, April 27, 2018 10:00 AM
  • So, for those that encounter this in the future, I had some bad code in my function. I was trying to log an error and inadvertently used context.error (thinking I was using console.error). The code failed at launch (which is why I wasn't seeing any output from the function. As soon as I changed the offending code to context.log.error() everything worked. 

    2018-04-27T09:54:19.389 [Error,SingleUseSet] TypeError: context.error is not a function
        at ClientRequest.postRequest.on.e (D:\home\site\wwwroot\SingleUseSet\index.js:80:17)
        at emitOne (events.js:96:13)
        at ClientRequest.emit (events.js:188:7)
        at Socket.socketErrorListener (_http_client.js:310:9)
        at emitOne (events.js:96:13)
        at Socket.emit (events.js:188:7)
        at emitErrorNT (net.js:1277:8)
        at _combinedTickCallback (internal/process/next_tick.js:80:11)
        at process._tickCallback (internal/process/next_tick.js:104:9).

    Friday, April 27, 2018 11:01 AM