I have an Azure Web App that communicates with a 3rd party system thru VPN / VNET integration. Part of that communication relies on being able to resolve a DNS name.
When the app is deployed to a virtual machine, we just update the hosts file with an entry like
123.45.67.89 RPGMDR500-0R
and the communication works fine. Because of the way the communication is setup, I cannot just use the IP address in code. In the communication the DNS name is sent back to us and we have to resolve it to that ip address.
Is there a way to do this with just an App Service? Effectively, we want the app to resolve this custom dns name to the ip address.
UPDATE I updated our VNET DNS Servers to use a Virtual Machine setup for DNS.
Using nameresolver, I can see that the DNS is reaching the app service, but only if I specify the DNS IP address. By Default, it is still using a Default Server (which not sure how). (sorry for the blackouts, not sure how sensitive those datas are).
As far as I know, we have no permission to access the disk C in the azure web app.So we couldn't change the hosts file in the azure web app.
Image like below:
Here is a workaround, if you use http to access the vnet, you could change the request host header to change the dns name in the code by using HttpRequestHeaders class.
More details, you could refer to below code sample.
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(@"http://111.111.111.70");
client.DefaultRequestHeaders
.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));//ACCEPT header
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, @"http://111.111.111.70");
request.Headers.Host = "DNS name";
var re= client.SendAsync(request).Result;
It is a lot of overhead to set it up but you could set up a DNS server in an Azure Virtual Network and then use the VNet Integration feature with your app. Your app would then use the DNS of your VNet which you could configure as you see fit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With