Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure App Service internal DNS resolution

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.

VNET using 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).

nameresolver

like image 476
MPavlak Avatar asked Jul 21 '17 17:07

MPavlak


2 Answers

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:

enter image description here

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;
like image 169
Brando Zhang Avatar answered Sep 18 '22 22:09

Brando Zhang


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.

like image 41
Christina Compy Avatar answered Sep 20 '22 22:09

Christina Compy