How do I connect to Azure SQL Database using Private Endpoint trough VPN gateway - azure

PROBLEM:
I'm able to connect to the Azure SQL Database using the private link from VM within the virtual network, but not from my pc trough virtual network gateway
In sqlserver1 firewall, I have denied public network access.
From MyVM in the myvnet, I'm able to connect to the sqlserver1 using FQDN. nslookup shows correctly private address 10.0.0.4
I connected my pc to the vnet using the gateway. I'm able to ping MyVM using private adresss 10.0.0.5.
When I try to connect to the sqlserver1 using FQDN, I get error:
An instance-specific error occurred while establishing a connection to
SQL Server. The public network interface on this server is not
accessible. To connect to this server, use the Private Endpoint from
inside your virtual network. (Microsoft SQL Server, Error: 47073)
So it looks like that it's using the public dns record and not the private dns zone that I have created with the private endpoint. How can I connect to the database?

In this case, you can use NSLOOKUP FQDN on the PC to verify if the private DNS zone issue.
You need to correctly configure your DNS settings to resolve the allocated private IP address. You can follow On-premises workloads using a DNS forwarder and this blog about Azure SQL DB Private Link / Private Endpoint - Connectivity Troubleshooting.
It's not recommended to override a zone that is actively in use to
resolve public endpoints. Connections to resources won't be able to
resolve correctly without DNS forwarding to the public DNS. To avoid
issues, create a different domain name or follow the suggested name
for each service below.
To configure properly, you need the following resources:
On-premises network
Virtual network connected to on-premises
DNS forwarder deployed in Azure
Private DNS zones privatelink.database.windows.net with type A record
Private endpoint information (FQDN record name and private IP address)

Related

Azure Postgres Flexible Server - Vnet integration DNS not resolving

I provisioned the resources accordingly to the documentation.
https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-networking
I did the provisioning using BICEP.
The name of the server is my-dev-db and I created a DNS private zone:
my-dev.postgres.database.azure.com
Now what I see, is that from my local computer, so public internet, I can ping both
my-dev.postgres.database.azure.com
and
my-dev-db.postgres.database.azure.com
I created a VM in the same VNET and I managed to connect via postgres client, but, not to the private DNS, my-dev.postgres.database.azure.com but to the my-dev-db.postgres.database.azure.com which is the one automatically created by azure as server name. When I try to connect with the private DNS it doesn't resolve.
So my question:
Why can I ping both dns from outside Azure.
Why the private dns doesn't resolve in the VM.
Really can't make sense of this behavior.

Access Azure Private Endpoint Using Azure VPN

I am trying to access resources that are secured behind private endpoint from a remote location using an Azure VPN Point-to-Site connection.
So far I have setup a conditional forwarder to send DNS requests to Azure's internal DNS IP address (168.63.129.16). With my setup I can resolve all my private endpoints using nslookup to their private IP addresses. I can also connect to services such as SQL server from my local machine (using SQL Server Management Studio in the case of SQL server).
The problem I am facing is that I can only access resources if I use a desktop client for a given service. If I try to do anything using the Azure Portal, I get an error stating that I cannot access resources using my Public IP address without adding it as an inbound IP address. Whilst this is certainly an option, I don't want to go down this road.
I am hoping there is an option where I can connect to private endpoint resources from Azure Portal whilst connected to my point-to-site VPN. Any ideas?
So far I have setup a conditional forwarder to send DNS requests toAzure's internal DNS IP address (168.63.129.16). With my setup I can resolve all my private endpoints using nslookup to their private IP addresses. I can also connect to services such as SQL server from my local machine (using SQL Server Management Studio in the case of SQL server.
AfAIK, the process which you are doing is correct, To fix this issue try to update the local host file on client desktop to deploy a recourse with private endpoint please refer this link for more in detail
By default when you create a Private Endpoint in the Azure Portal it will automatically lock out public access. Service Endpoints operate by adding routes to allow traffic out of the virtual network to reach the public endpoint of the service selected. If you are access resources error, update firewall rules to communicate with your Azure resources you really need to configure v-net traffic on the firewall settings
Next option is conditional forwarder, in your scenario the ble from every v-net, its public ip it won't overlap with any private ips, it available from inside of azure v-net unique to each
In conditional for forwarder, client asks the ip of a host like www.seraltos.com .The dns server looks to see the answer if knows, if not a lookup will done based on root servers or forwarder to find the ip address returns that to the client
For more information in detail, please refer below links:
Private Endpoints and DNS in Azure & Cannot access my own public IP
https://learn.microsoft.com/en-us/azure/storage/common/storage-private-endpoints
https://learn.microsoft.com/en-us/azure/private-link/manage-private-endpoint?tabs=manage-private-link-powershell

Azure Private DNS configuration not working with P2S VPN

I have hosted my web application in azure, My team accessing my application vi application gateway private ip using Azure P2P VPN connection. My application is working with private IP, I want to configure dns name and ssl certificates for my private ip.
Following things I have tired so far
Created Azure Private DNS Zone and Linked my VNets
Created A records for my private ips
Added dnssuffixes in azurevpnconfig.xml (Azure VPN Client configuration)
I tried accessing test.demo.com, I'm getting site not be reached
Not sure what I'm missing
Clarification would be helpful
Azure wont support private dns configuration for P2S VPN connection ?
Any other workaround to achieve dns and SSL configuration for private IPs ?
Reference :
https://learn.microsoft.com/en-us/answers/questions/64223/issue-with-resolving-hostnames-while-connected-to.html
https://learn.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-troubleshoot-vpn-point-to-site-connection-problems
As per Name resolution for resources in Azure virtual networks:
In order for the P2S VPN clients to be able to resolve Private Endpoint entries hosted on Azure Private DNS Zones, you must leverage an existing DNS Server (Forwarder or Proxy) or deploy one IaaS VM using a DNS Server role. That is required to P2S VPN clients be able to consume Azure Private DNS Zone which is exposed to 168.63.129.16 via DNS Forwarder/Proxy.
Once you have a DNS forwarder/proxy deployed on Azure, you can define the DNS server at the VNET level or set DNS Server configuration directly on client XLM profile. Post this, you will be able to resolve Private Endpoint entries from your P2S clients.
Refer : https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns#on-premises-workloads-using-a-dns-forwarder
https://github.com/dmauser/PrivateLink/tree/master/DNS-Integration-P2S

Unable to connect Azure Database for PostgreSQL servers from Azure function app

We have created the Vnet with virtual network gateway for point to site VPN, PostgresDB, Azure function APP.
We are able to establish connections with a point-to-site VPN.
Configuration:
Resources configuration in Azure functions:- Private endpoint and
vnet integration.
Resources configuration in PostgresDB:- Private endpoint and in
connection security set Deny public network access to "Yes"
If in PostgresDB we configured Deny public network to "No" then azure function communicating to Postgres DB and works find.
Issue :
when we are trying to access Azure DB from Private function with hostname its failed to establish the connection but it works if we replace Azure DB hostname with private IP.
Same with VPN connection when we try to connect Postgress DB with server name it doesn't work but works with private endpoint IP.
Error:-
Result: Failure Exception: OperationalError: FATAL: The public network access on this server is disabled. To connect to this server, use the Private Endpoint from inside your virtual network.
we need a solution to create a connection between the azure function to private Postgres DB.
In order to solve the above issue, please check the below points.
Enable private endpoint at Azure Function & DB
If you are denying the public network access to 'Yes' then you need to make allow Azure Service to 'Yes' and add Vnet Rule with function subnet.
Go to the private DNS zones and check vnet(Vnet in which DB & Function created) are added into the private DNS zone.

Unable to connect Azure Function with Azure SQL using private endpoint

I've created a SQL Server and then created a private link with my TESTVNET/SUBNET1 with private IP 10.1.1.4. I've now disabled Public access for the SQL server.
I have an Azure function running on App Service which I've VNET Integrated with VNET/SUBNET2.
Subnet 2 shows it's delegated to server farms. (also if someone can explain what does delegate to means, I found I cannot create any VM in that subnet as well, probably it's just can't be useful for any other purpose)
Now when my azure function tries to connect to DB. it fails with below error:
2020-08-30T15:25:45.216 [Error] Unhandled rejection SequelizeAccessDeniedError: Cannot open server "10.1.1.4" requested by the login. The login failed.
However, if I give the public FQDN it gives me below error.
2020-08-30T15:29:43.654 [Error] Unhandled rejection SequelizeAccessDeniedError: Reason: An instance-specific error occurred while establishing a connection to SQL Server. The public network interface on this server is not accessible. To connect to this server, use the Private Endpoint from inside your virtual network.
Here the Private DNS created by Private endpoint should have been ideally used to get the private IP of the SQL database, but it seems the function is not using the private DNS probably because not running in an isolated environment.
Now in my Azure function Application settings, I've added WEBSITE_VNET_ROUTE_ALL =1 which should mean that all the requests should be routed to VNET. So now If I enable public access internet, and allow Azure services to access DB (I think azure added the public IP by default). The function gets connected to the DB.
Now I want to understand where I'm going wrong and why is the private endpoint connection not working. Any help is appreciated.
In the DB firewall settings, I've allowed traffic from below to subnets:
Network Configuration
TESTVNET: 10.1.0.0/16
SUBNET 1: 10.1.1.0/24
SUBNET 2: 10.1.2.0/24
I've disabled Service endpoint for SQL in both SUBNET 1 and SUBNET 2. My NSG has default settings i.e.
AllowVnetInBound, AllowAzureLoadBalancerInBound, DenyAllInBound
AllowVnetOutBound, AllowInternetOutBound, DenyAllOutBound.
Since my private link has a private IP present in the same VNET I don't think NSG should have any impact.
New to Azure, testing things out. Thank you for your patience.
To make Azure Function connect to a private endpoint you will need to use VNET integration.
After your app integrates with your VNet, it uses the same DNS server that your VNet is configured with. By default, your app won't work with Azure DNS Private Zones. To work with Azure DNS Private Zones you need to add the following app settings:
WEBSITE_DNS_SERVER with value 168.63.129.16
WEBSITE_VNET_ROUTE_ALL with value 1
These settings will send all of your outbound calls from your app into your VNet in addition to enabling your app to use Azure DNS private zones. Reference here.
Then you could set up Private Link for Azure SQL Database. You can create an Azure VM from a new subnet in the same VNet to check connectivity using SQL Server Management Studio (SSMS). If you enable the private endpoint, you should get a client private IP from that Azure VM to connect the Azure SQL database with its FQDN.
For more information, you could read private endpoint VS service endpoint in this blog.

Resources