Application Gateway Rules need recreating after private DNS is updated - azure

I have an application gateway which has a routing rule. The routing from application gateway to the VM is based up FQDN (I use Azure private DNS to internally map the VM IP to the FQDN).
To switch traffic to a different VM (as part of an upgrade pipeline) I update the private dns with the new machines IP.
This results in the backend health failing.
Oddly, manually updating the backend pool, or the routing rule in exactly the same form resolves this issue.
Any ideas whats going on? It feels like its caching the DNS?

There are at least 2 solutions.
Stop/Start application gateway: https://learn.microsoft.com/en-us/cli/azure/network/application-gateway?view=azure-cli-latest
Re-write any of the application gateways config as part of the deployment pipeline
In my case I chose to switch from routing based of FQDN to that the IP address of the VM.
This makes use option 2.

Related

Azure Virtual Machine cannot resolve DNS entry of Application Gateway

I have the following situation:
If I deploy an application (Deployment, Service and Ingress) in my kubernetes cluster, my ingress deployment is being automatically added to my application gateway (I am using the Azure Application Gateway Ingress Controller; https://azure.github.io/application-gateway-kubernetes-ingress/annotations/ ). So far so good.
That means that my application can be reached via my application gateway via https://my-app-gateway-public-ip/myAppPath/. Also, I have an additional private DNS zone which makes my app accessible via https://dns-name/myAppPath.
Additionally, we have an AADDS in combination with a Bastion Service. Deployed some virtual machines and the virtual machines use the DNS resolver of the AADDS (for authentication against the AAD).
The problem is: If I am outside of the cloud, I can nslookup the dns or can access the site via the ip, but I cannot do that with my virtual machines. My DNS server (within the AADDS) is unable to resolve the dns or accessing the ip. I am wondering what the issue is.
The bastion and AADDS are in different subscriptions and therefore different virtual networks. I established already a peering between those virtual networks (or the authentication between the AADDS and the VMs wouldn't work).
The kubernetes cluster and the application gateway are also in a different subscription, but no peering has been done so far.
Are there any hints what I could be missing?
Kind regards
• Since, you are using a Bastion gateway server to connect to the VMs hosted in your subscription, the Bastion gateway server must be having a public IP address through which then the registered underlying VMs can be connected to via private links created in the private DNS zones associated with a particular virtual network in a subnet and an assigned private IP address and a FQDN accordingly. Thus, if you want to access the application website hosted behind the application gateway, then you will have to create a conditional forwarder in the DNS zone in AADDS to redirect the internal requests from the VMs hosted within a virtual network to the public IP address of the website hosted behind the application gateway
• Thus, a conditional forwarder forwards the DNS resolution requests for a particular resource hosted on the public internet for which the DNS host resolution is not found or done in that DNS zone which usually serves or fulfils the requests related to internal environment. As a result, when a VM configured with a private IP is registered as a host in the internal DNS zone queries the public IP or FQDN associated with the application’s website, the DNS requests are forwarded to the public internet through the conditional forwarder and then the results are displayed in the VM’s browser for the application’s webpage. Thus, the VMs don’t need to have internet access but the DNS server should have or should forward the requests through the Internet proxy server accordingly to reach the internet.
For more information on creating conditional forwarder in AADDS, kindly refer to the below link: -
https://learn.microsoft.com/en-us/azure/active-directory-domain-services/manage-dns#create-conditional-forwarders

Is it possible to create the equivalent of a hosts file in an azure web app

I'm migrating asp.net services that used to exist on a physical server on-premise to Azure. However they need to reach some web-services (SOAP) that will not be migrated to azure yet. These have a public IP but I need to set the hostname in order for IIS to properly redirect the requests to the correct service as there are several on the same server. Is there any way to create some sort of DNS-server in azure that is only available for the services created in azure that can resolve to the public IP-address outside of azure? (We have used the hosts file on the servers to achieve this previously)
I tried using the private DNS Zones, but as I've understood it they can only point to other azure services within the same vnet (correct me if I'm wrong). I've also tried creating a dnsmasq docker container. However, as this is running in a Linux container, it seems that I cannot put it in the same vnet as the asp.net app services. Thus I am unable to retrieve a private IP-address that these services can use to reach the DNS server.
In my understanding it is now possible to use Azure DNS Private Zones if you want.
You would need to use regional vnet integration to point your app's traffic to a vnet that is connected to the Private Zone. You need the following settings as well, which mean that all outbound traffic from the Web App is routed through the integrated vnet first, and that the Azure default DNS server is used for DNS.
WEBSITE_DNS_SERVER with value 168.63.129.16
WEBSITE_VNET_ROUTE_ALL with value 1
https://learn.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#azure-dns-private-zones
If you don't want to use Azure DNS Private Zones, I think you can achieve similar results by directing the Web App to use a specific DNS server. This can be done using WEBSITE_DNS_SERVER and WEBSITE_DNS_ALT_SERVER app settings (the values are the IP addresses of the servers you want to use).
This is the most authoritative public statement I can find about using these settings.
Go to the web app->settings->Application Settings-> App Settings
section
Add the following: (WEBSITE_NODE_DEFAULT) should already be
there.
a. WEBSITE_DNS_SERVER with value having the IP address of the
primary DNS server.
b. WEBSITE_ALT_DNS_SERVER (optional), with value
having the IP address of a second DNS server.
Then save the settings & restart webapp in portal.
Double check the web app can actually
connect to the DNS server: a. In kudu console, run: Nameresolver.exe
[hostname-to-lookup] [dns-server-to-use]
First argument should be the
hostname you are trying to look up, second argument is one of the DNS
servers from step 1) If this times out, there is an issue with how
your DNS servers are configured (firewalls, etc.)
https://github.com/MicrosoftDocs/azure-docs/issues/13927#issuecomment-416382230
If using these settings with a DNS server that is only accessible via private IP, you would need to use regional vnet integration again to connect to a vnet. If the DNS server is on-prem, you have to connect through the integrated vnet over VPN or ExpressRoute.
It's possible but not using the private DNS Zone.
According to Name resolution for resources in Azure virtual networks. For the scenario Name resolution from App Service Web Apps in one virtual network to VMs in a different virtual network, you need to use your own DNS servers forwarding queries between virtual networks for resolution by Azure (DNS proxy). See Name resolution using your own DNS server.
In this case, you only allow this azure web service could resolve the public IP address outside of Azure. You could enable virtual network integration for your web app, this restricts your web app access in a private network. Then you could deploy a DNS server in the same Vnet as the web app integrated VNet. You could create an A type record in your DNS zone to point to your service Public IP, then add the DNS server's IP address into the DNS server of the Integrated web app Vnet in the portal. If so, the web app could resolve this public IP via a custom DNS server.
Hope this could help you.

How to configure ssl with azure application gateway?

I have to configure my Microsoft Azure server like below scenario
So it is like a request comes with a public IP which represents application gateway having SSL and the request passes from app gateway to the load balancer.
LB just forward to the virtual machine(having SSL) on the basis of the port number.
Here there is only one public IP and virtual machine selected according to the port.
I made the configuration but the only thing I am missing that is SSL configuration with Application gateway and same SSL in a virtual machine.
I don't know my configure pattern is right or wrong please suggest me if you have a good option.
My goal is to achieve the request (with the public IP) passes from the application gateway having SSL to the virtual machine also having the same SSL on the basis of ports with the same public IP, Is there any better option than my configuration pattern?
Please help me, How to achieve it.
You can use the following Settings in Application Gateway and you don't need ILB in-front of your VM.
Create a Application gateway. Create 3 Multi-site Listener. Upload Certificates and enter Host Name and the respective ports.
Create 3 Backend Pool and add your VMs to it.
Create 3 HTTP Settings. Upload authentication certificates and configure respective ports. Create and attach Health Probes to HTTP Settings.
Create rules where you link corresponding listeners with HTTP Settings and backend pool.
Check if the Health Probes are healthy. If yes, then your setup is complete.
In Application Gateway you can achieve end to end SSL and you can create multiple HTTP Settings with different SSL port to achieve this without ILB.
If that is the case you will not get the High Availability as you only have one VM for each SSL port.
Can you explain why you need to use different SSL port for each Machine? Are you hosting multiple Site?
If yes, you can easily achieve with Application Gateway. Please let me know your entire setup and if you have any follow up questions. I am here to help you.

How to redirect traffic hosted on an azure endpoint (DNS/static IP) to different external IP address

Question: How do I host an endpoint in azure which allows me to redirect internet traffic at will between azure and aws services?
I am hosting two kubernetes clusters - one in Azure and the other in AWS. I want to be able to:
1. redirect the traffic at will to either aws or azure, whilst retaining the public dns endpoint.
2. fail over manually [and pref automatically too] to the aws cluster. What is the best way to host the endpoint in azure?
Requirements:
The traffic needs to be redirected immediately - no caching issues and stale loads!
Ability to configure failover - i.e. specify that Azure is hot and AWS is the failover service - the traffic should be automatically redirected as soon as Azure goes down.
I have looked at Traffic Manager, Load Balancers and Application Gateway. Not sure which one (if any) of these is best.
traffic manager wont work for you, since its a dns service, so caching will happen (admittedly its the best solution if you set dns cache to 5 seconds or something). application gateway allows you to specify an ip address as an endpoint, load balancers only work when attached to vms inside azure. But application gateways dont allow to failover at will. you would need to block the probe to failover.
Azure Front Door might be the solution for you (like the other answer mentions)
You can have a look into Azure Front Door Service for your usecase.
Look into this https://learn.microsoft.com/en-gb/azure/frontdoor/front-door-overview

Azure private DNS zone resolving

We have a private DNS zone setup for the zone project.local. For app service instances living in an app service environment, each service has its own record pointing to the load balancer in front of the service (so all have the same IP).
We have an App Gateway instance linked to a public IP in front to make this all publiccally available. The gateway is available via a public URL and routes the request to the load balancer.
Now what we see is the following:
From external, everything is fine. We can get to the services using the external URL, gateway forwards it and all is well.
From internal, we want to use the internal DNS address set in the private zone. This is not working, calls from service to service throw an error stating that the host URL could not be resolved.
When I log into a VM in the same vNET or use the Kudu console, I'm able to resolve the DNS address to the correct IP. What I do notice is that when using nslookup, it says it's getting a non authoritative answer.
It's very hard to get any more information for debug purposes. We're not sure why resolving isn't working as per documentation these records should work for all of the components in the same vNET. The authoritative error might be related, but again: not sure. So any ideas on what else to check would be highly appreciated.
Disclaimer: I also have a support ticket open for the same question, but wanted to put this out there to see if there's anyone else who might have encountered the same since this is pretty new tech.
Azure DNS Private Zones are able to resolve names between VMs and Cloud services. It does not look like it can be used by Azure Web Apps or Azure App Services at this time. 
You can see more information on name resolution for resources in Azure Virtual Networks Here.
If you would like to request this feature be added to DNS Private Zones, you can leave your feedback Here.

Resources