No access to the website from Azure Container Instance using a private network with custom DNS server - azure

I have Virtual Network with two subnets (A and B). Vnet is configured to use a custom DNS server. In one subnet (A) I have a web server which has an appropriate DNS configuration. If I create a VM inside subnet A and I try to open a website using DNS, then everything is working correctly. Subnet B is fully dedicated to Azure Container Instances. When I create a container group with one container (azure cli), and I try to connect to a website, I get an exception that page is not available. It seems that my container instance is not using my custom DNS server assigned for the virtual network. Any ideas what may be wrong?

When ACI is deployed to an existing vnet and the vnet is configured with the custom DNS server, ACI will not inherit the custom DNS servers. You need to deploy the ACI through YAML file and specify the DNS server in the specification of dnsConfig.
For example, below YAML file, to deploy an ACI with Nginx image in an existing vnet using network profile and configure custom DNS servers. Refer to this.
For more reference, you could read YAML reference: Azure Container Instances

Related

Cannot access Private AKS cluster from Local Machine (on home network) connected to Azure VPN

I have a Private AKS cluster deployed in a VNET on Azure. Once I deployed it, a private endpoint and a private DNS zone were created by default therefore making the cluster accessible from VM's which are part of the same VNET. (I have a VM deployed in the same VNET as the AKS cluster and "kubectl" commands work in it.)
My requirement is that I want to perform the "kubectl" commands from my local machine (connected to my home network) and also connected to the VPN which connects to the VNET.
My machine can talk to resources within the VNET but cannot seem to resolve the FQDN of the private cluster.
I read somewhere that having a DNS forwarder setup in the same VNET can help resolve the DNS queries made from the local machine which can then be resolved by Azure DNS. Is this the way to go about this? Or is there a better way to solve this problem?
It would really help if someone could give me an action plan to follow to solve this problem.
The better way to perform the "kubectl" commands from your local machine to your private AKS cluster is to use AKS Run Command (Preview). This feature allows you to remotely invoke commands in an AKS cluster through the AKS API. This feature provides an API that allows you to, for example, execute just-in-time commands from a remote laptop for a private cluster. Before using it, you need to enable the RunCommandPreview feature flag on your subscription and install aks-preview extension locally. However, there is a limitation that AKS-RunCommand does not work on clusters with AKS managed AAD and Private link enabled.
In this case, If you want to resolve the FQDN of the private cluster from your on-premise network, you could select to use either the hosts file locally(used for testing) or use your DNS forwarder to override the DNS resolution for a private link resource like this.
The DNS forwarder will be responsible for all the DNS queries via a server-level forwarder to the Azure-provided DNS 168.63.129.16.You can provision IaaS Windows VM with DNS role or Linux VM with bind configured as a DNS forwarder. This template shows how to create a DNS server that forwards queries to Azure's internal DNS servers for Linux VM. Refer to this for DNS forwarder on Windows VM.
If there is an internal DNS server in your on-premise network. The on-premises DNS solution needs to forward DNS traffic to Azure DNS via a conditional forwarder for your public DNS zones(e.g. {region}.azmk8s.io). The conditional forwarder references the DNS forwarder deployed in Azure. You could read this blog about DNS configuration sections for more details.

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 access Azure VM from App Service in virtual network by private DNS name?

VM and App Service are located in the same Virtual Network.
App Service is added to VM through VNet Integration (preview)
VM is autoregistered in Private DNS zone, say by name myvm1. And full name myvm1.priv.zone
Private DNS zone is linked to Virtual Network.
Virtual Network - DNS Servers is set to default.
VM and App Service were restarted after configuration.
Problem is I can resolve neither myvm1 nor myvm1.priv.zone from App Service console by nameresolver.exe
UPDATE:
Actually, the issue is even bigger. App Service is not able to send requests to VMs in Virtual Network by their Private IPs (10.1.x.x) even if everything is allowed on VMs' subnet. If the same requests are sent to VMs' Public IPs there is no problem.
As the existing answer, for scenario Name resolution from App Service Web Apps to VMs in the same virtual network. in this DOC, you need to deploy your own DNS server to help name resolution.
Here are the steps:
On the Azure VM in the VNet, add a server role DNS server, after the installation, configure the DNS server, add Zone name such as qaz.lab in my example. You also can manually add an A record for your Azure VM in this Zone.
Add the DNS server private IP address in the custom DNS server of Azure VNet. Then restart the Azure VM to make it effective.
Configure VNet Integration with your app, in this case, select the new VNet integration. After that, refresh your VNet Integration. You will see the DNS server update in your app service plan --- networking.
Navigate your app service, run nameresolver FQDN to validate the DNS resolution. Currently, It only supports FQDN resolution.
Let me know if you have any question.
As of today, you need to use DNS proxies or forwarders to achieve your ask. It is documented here in the scenario table.
For scenario "Name resolution from App Service Web Apps to VMs in the same virtual network.", the solution is to "Customer-managed DNS servers forwarding queries between virtual networks for resolution by Azure (DNS proxy)."
On How to perform "Name resolution with your own DNS" check here, where your scenario is described.

Azure Container Instance - dns and subnet in the same container

I have an Azure Container Instance with subnet configuration (I need to access an internal service). But I also need to configure dns.
I try to create the Container, but it returns this message: The IP address type can not be public when the network profile is set.
Is it possible to configure dns and configure the subnet in the same container?
Unfortunately, if you deploy the Azure Container Instances in the Subnet of a Vnet, then you cannot set the public IPs or DNS for it. Azure does not support it, at least now. Maybe it will be supported in the future. For more details, see Virtual network deployment limitations.
Container groups deployed to a virtual network do not currently
support public IP addresses or DNS name labels.
Hope this will help you.
The error with the network profile looks like a bug in the az
command tool. If you just specify your VNET name and subnet name
then it will create a network profile name.
If you want to use DNS
to resolve these names you'll need to setup DNS separately, and call
an additional az command to configure the DNS after you create the
container instance.
az network dns record-set a add-record ...
See this doc for using Azure DNS with private IP addresses.
Use Azure DNS for private domains

Azure DNS (reddog.microsoft.com) 10.0.1.4 Virtual Machine Template

I'm using a template to deploy an elastic cluster and am having issues with the nodes setting up/deploying correctly when I choose my own subnet. It seems this is due to how the Virtual machines by default seem to have a DNS record for their private IP address. But In my case this isn't happening.
Azure DNS (reddog.microsoft.com) 10.0.1.4
What is this DNS server?
Where is it hosted?
Is it automatically deployed to every VPN?
Why do some machines automatically get a record entry and others not?
How can I ensure that machines get an entry?
I am currently trying to use a template to deploy Elasticsearch. If I deploy elasticsearch by creating a subnet during deployment then I get host entries on each ubuntu VM in /etc/hosts and also an A-Record for each VM in this DNS server. The deployment is successful.
If however I choose for the template to deploy in my own subnet I find that the machines don't have each other in /etc/hosts and the DNS server doesn't contain an A-Record and therefore can't resolve each other via name. Deployment therefore fails.
The template I am deploying via the Azure portal UI:
Elastic Stack - (Elasticsearch, Kibana, X-Pack)
Any help appreciated,
Thank you
based on the IP and the dns search suffix, that a custom DNS server. The would be configured as part of the virtual network properties or as part of the dns settings on the individual NIC.

Resources