Azure-docs: Is a WebJob unable to make a request of the site it is running under?

Created on 19 Jun 2019  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

In the Network Access section, the documentation states:

There is also a limited capability for apps to establish one local loopback connection, 
and have an app listen on that local loopback socket. This feature exists primarily to enable 
apps that listen on local loopback sockets as part of their functionality. Each app sees a 
"private" loopback connection. App "A" cannot listen to a local loopback socket established by 
app "B".

If I have a WebJob setup to access an end point on my site every 5 minutes because I want to trigger code which calls another API that doesn't have a webhook, will it fail because the WebJob is considered app "B" and the App Service is considered app "A"?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

app-servicsvc cxp product-question triaged

All 6 comments

@MarkIannucci, Thanks for the question! We are taking a look into this and will get back to you soon.

@AjayKumar-MSFT, thanks for looking into this. To be more specific, I have a PowerShell script which calls Invoke-WebRequest -uri $myUri -method GET. It is silently failing with this error:

Message        : The underlying connection was closed: An unexpected error 
occurred on a send.
Data           : {}
InnerException : System.IO.IOException: Unable to read data from the transport 
connection: An existing connection was forcibly closed by the remote host.

By silently failing, I mean, kudu shows that the job ran successfully, even though PowerShell threw an unhandled exception. I am able to Invoke-WebRequest -uri "https://www.google.com" -methd GET without issue, so I'm wondering if this limitation is the root cause of my error.

@MarkIannucci, Azure Web Apps run in a secure environment called a sandbox. Each app runs inside its own sandbox, isolating its execution from other instances on the same machine as well as providing an additional degree of security and privacy which would otherwise not be available. Yes, it’s not possible for the WebJob to directly send requests to the site via localhost. This limitation is documented on the sandbox page.

@MarkIannucci, Since we have not heard back from you we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion.

thanks for the follow up @AjayKumar-MSFT . Ultimately, I decided to refactor the code to be fully contained within an Azure function which avoided this issue.

Mark, Thanks for the update and sharing the solution that worked for you.

Was this page helpful?
0 / 5 - 0 ratings