Can a precompiled Function App use Hybrid Connections to on-premise servers?

316 views Asked by At

Can a precompiled Function App use Hybrid Connections to on-premise servers?

I can access the on-premise server using a C# script Function App function ...

using (var client = new HttpClient())
{
    var result = await client.GetAsync("http://onpremisedev/dummywebapi/api/persons/1234");
    string resultContent = await result.Content.ReadAsStringAsync();
    data = resultContent;

But when I same C# code in a precompiled Function App function, I'm getting an exception that the server name can't be resolved ...

Exception while executing function: CallOnPremiseWebApi -> 
  An error occurred while sending the request. -> 
    The remote name could not be resolved: 'onpremisedev'

I've tried changing the server name to its FQDN, but no change.

Both Function App's are running in an App Service, i.e. not in Consumption plan

And the App Service has got the hybrid connection set-up to the on-premise server on port:80

How can the script version of the function resolve the on-premise name, but the precompiled version can't?

1

There are 1 answers

0
mfierro On

I had a very similar problem that might address your problem.

I had a v2 function app that used the Hybrid connection correctly and a v1 function app that would not (both hosted in the same app service)

After many frustrating hours, I realized that even though they were in the same app service, I had to go to Platform Features -> Networking -> Configure your hybrid connection endpoints for that function app.

Then I had to add the hybrid connection again. (It prompted me with a list of already existing connections in the App Service). Once I did that, it all worked as would be expected.