'Azure function call other API,failed with 'A connection attempt failed because the connected party did not properly respond after a period of time,,,'

Azure function (Timer trigger) uses Restsharp to make a REST call to an external API, which is failing with error

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. A connection attempt failed because the connected party did not properly respond after a period of time

The external API provider has added to the allow list all Azure function app Outbound IP's and local system IP. My code works locally well, but after publishing on Azure the Azure function throws this error.

We wrote code to get IP inside Azure function, and when azure function run on azure it gave one from outbound IP address and which is whitelisted.

Is there anything else that could block by firewall? What actually does the Azure Function do when it makes an outside call. Any reference please?



Solution 1:[1]

Thank you ZainD365 Posting your suggestion as an answer to help other community members.

A connection attempt failed because the connected party did not properly respond after a period of time,,,

"This error can be resolved by creating a Azure Virtual Network NAT gateway. Then whitelisiting the static ip addresses on the webservice firewall."

For more information about the similar issue please refer the below links:

GitHub issue: Troubleshooting HttpRequestException "A connection attempt failed because the connected party did not properly respond..."

SO THREAD : How to call an API using time trigger Azure function

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AjayKumarGhose-MT