MichaCo / DnsClient.NET

DnsClient.NET is a simple yet very powerful and high performant open source library for the .NET Framework to do DNS lookups
https://dnsclient.michaco.net
Apache License 2.0
781 stars 137 forks source link

Azure Functions - PlatformNotSupportedException unless you mannauly set IPEndPoint #133

Closed msdickinson closed 2 years ago

msdickinson commented 3 years ago

Hi, so I have been able to run in azure functions about a year ago but now I am trying again and finding failing.

System.InvalidOperationException: 'Error resolving name servers' PlatformNotSupportedException: Registry is not supported on this platform.

   var client = new LookupClient();

But the code below is functional. So again I assume this is in azure function not letting me grab the systems DNS settings, so I mannauly setting it works. Creating this here in case its useful for anyone but you can close the ticket.

   var client = new LookupClient(NameServer.GooglePublicDnsIPv6);
            var result = client.Query("google.com", QueryType.MX)
                                         .Answers.MxRecords().Any()
                                         ? ValidateEmailDomainResult.Vaild : ValidateEmailDomainResult.Invaild;
MichaCo commented 2 years ago

Hi @msdickinson, thanks for letting me know!

Never worked with Azure functions yet but I'll take a look into it. Its a bit strange because that path shouldn't run if it is not Windows. So that looks kinda like a bug

MichaCo commented 2 years ago

This should be fixed with 1.6, I did not test it in azure functions though but the PlatformNotSupportedException should be ignored now.

That doesn't mean that the library will find a DNS server in Azure Functions so you still might have to manually configure the client unless you can use public DNS servers