How to call an API inside an Azure ILB ASE from a webapp within the same ASE - azure

I have an Azure ILB ASE deployed, and a webapp deployed inside it at (for example) https://myapp.my-internal domain. I have an Application Gateway configured, mapping an external domain name to that app via the ILB, and this works well - I can connect to the webapp from the internet via the Application Gateway, as expected.
My webapp needs to talk to an API deployed to the same ILB ASE, at (for example) https://myapi.my-internal-domain - but when it tries to make this connection, it fails, being unable to resolve the internal domain name:
How can I configure my web app so it can find an api app within the same ILB ASE?

I will summarize the comment to let others who have same question get answer quickly.
To to manually overwrite the MS default DNS settings and use the internal DNS server for web app service, the solution is to add Website_DNS_Server= primary DNS server IP and Website_DNS_ALT_Server=secondary DNS server IP” under the App Settings in webapp.
Don't forget to point the address of each app to the ILB private IP in Azure DNS zone.
For more details, you could refer to this article.

Related

how to add forward proxy to azure app service

I have azure app service which runs .net core web api. This api access several external API s to get data and those external services has to whitelist the outbound ip addresses of my app service.
Azure app service has several outbound ip addresses and it can be change when upgrade/downgrade app service or when make internal changes like changing app service plan or resource group.
Is there any solution in azure to setup this app service behind a forward proxy ?, so i can share the IP of the forward proxy to external parties.
I think the best way would be to add all App services under a virtual network and create a Virtual Network Gateway to all outbound connections.
This would potentially need below azure services to be created:
- Virtual network
- Subnet
- Virtual Network gateway
- Routing tables (to route traffic via Gateway)
A better way would be sharing a domain name rather than IP address. Here's how to configure it directly in the Azure Portal:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain
You can also add an API Management in front of your web app and use it as API gateway and also apply policies on it.
https://learn.microsoft.com/en-us/azure/api-management/configure-custom-domain

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 will fix Inaccessible issue for function app created in ILB ASE in azure?

I am trying to create a function app in azure ILB ASE but failed to open Kudu due to its inaccessibility. How I configure it correctly?
Since the Azure function is deployed in ILB ASE, it can only be accessed from the virtual network. If you want to access the function outside the VNet, you need to deploy a public Azure application gateway to expose the internal endpoint. The Azure application gateway will work as a reverse proxy to route the incoming traffic to the appropriate endpoint.
References:
Integrate your ILB App Service Environment with the Azure Application Gateway
Private Function Apps in Azure Government using App Service Environment (ASE)
Take a look at this issue - Document how to use Functions in an ILB ASE and this link, make sure you meet the requirements.
Be in the same vnet as your ILB ASE
Have a valid cert for the default domain and the default scm domain. *.yourILBDomain.com and *.scm.yourILBDomain.com
In addition to having a certificate, you also must configure the DNS for the ILB domain.

How to keep web app to api app calls within ILB ASE

I have web and api app deployed within ILB ASE fronted by Application Gateway.Would I be able to make the calls from my web app to api app without exposing api app externally? If so, how can I do that?
I configured application gateway to point to the front end web app. I created internet routable domain and added to custom domain in my web app. In my DNS, I pointed the custom domain to hostname of the application gateway and I am able to logon to my web app. But, I see my web app written in AngualarJS is making XMLHttpRequest to backend API URL and as the backend API URL can not be resolved from my desktop, it is failing.
My requirement is not to expose API app outside of the ILB ASE VNET. Any suggestions?
If you want the web app and API could communicate with each other in an ILB ASE, you need to deploy an internal DNS service. For example, you could deploy a custom DNS server on Azure VM in the same Azure VNet. You can specify DNS server IP addresses in the VNet settings. The VNet is your ASE subnet located.
Please note that restart ASE after DNS IP address is added to VNet if you add the DNS after you deploy ASE. You could refer to this and read more details about custom DNS in ASE. Let me know if this works.

Can my Azure web apps access the internal DNS of my Virtual Network?

I have configured my Azure Web Apps and App Hosting Plan to connect via Point-to-Site gateway with my Virtual Network in Azure. I followed this article here:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-integrate-with-vnet/
I have a VM that is hosting DNS and my Virtual Network is configured to use this.
I want to be able to reference services running in my Virtual Network from my Web Apps via domain name and not by direct IP address.
It works fine if I connect using the VM's internal IP address eg 192.168.1.4. But, when I add a DNS A record pointing my-service.my-vnet.local to 192.168.1.4, my web app can't resolve the domain.
I attempted to check the DNS settings of the web app and it appears my internal DNS server is not one of the hosts configured. Here's the code I ran in my web app:
from nic in NetworkInterface.GetAllNetworkInterfaces()
let props = nic.GetIPProperties()
select String.Join("; ", props.DnsAddresses.Select(x => x.ToString()))
Is this possible to do? If so, can anyone suggest what I need to do?
From everything we have tried and talking with Azure folks at Ignite, Web Apps (point-to-site) were not designed to be joined to a domain. That said, we are successfully using web apps to access on-premise web services using a binding with a fully qualified domain name (FQDN) and securing that traffic be certificate.
Due to the way web apps connected to a VNET works, you will not be seeing the DNS servers when you list all interfaces. If in command line you run the command:
SET WEBSITE_
You should see an environment variable that holds your configured DNS servers. If not, you should go to your web app in the Azure Portal, to the Vnet section, and hit the "Sync Data" button.

Resources