Azure elastic jobs not working when using a private endpoint - azure

I'm trying to set up elastic jobs to run a procedure on another database.
I set up code to run as below:
EXEC jobs.sp_add_target_group 'DatabaseGroup'
GO
EXEC jobs.sp_add_target_group_member
'DatabaseGroup',
#target_type = N'SqlDatabase',
#server_name='test-db01.database.windows.net',
#database_name =N'TEST'
GO
EXEC jobs.sp_add_job #job_name='Hourly Update', #description='Runs Hourly Update',
#schedule_interval_type='Hours',#schedule_interval_count=1
EXEC jobs.sp_add_jobstep #job_name='Hourly Update',
#command=N'exec [TT].[HOURLY_UPDATE]',
#credential_name='JobRun',
#target_group_name='DatabaseGroup'
EXEC jobs.sp_start_job 'Hourly Update'
So when i submit my job to run
I got the following error:
Failed to connect to the target database: Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes
To connect to this server, use the Private Endpoint from inside your virtual network
(Msg 47073, Level 14, State 1, Line 65536)
So my private end point name is called db01.test.****.com <- confidential name used
So I recreate the group_member & resubmit job again
EXEC jobs.sp_add_target_group_member
'DatabaseGroup',
#target_type = N'SqlDatabase',
#server_name='db01.test.****.com',
#database_name =N'TEST'
GO
The new error below is:
The server 'db01.test.****.com' cannot be used as a job target because it is not an Azure SQL Database server in the same Azure cloud as this job agent.
The server's fully qualified host name must end with '.database.windows.net'.
So any ideas how i can get around this scenario & get my job to submit

Your private endpoint should still be registered in Azure DNS using the 'database.windows.net' domain suffix. If you've created your own internal A records on your own managed DNS servers this would be the expected behavior.
A quick workaround on this is to put modify your HOSTS file on your source system using the Private Endpoint IP and the FQDN and it should work. Managing HOSTS files is not something you want to do for any period of time.
If you're running this all from within Azure, you should be able to leverage Azure DNS. - - Create a zone called 'privatelink.database.windows.net'
Create an A record with your Db01 & Private IP Address in this zone
On your VNET - check to see if your using Azure DNS or Custom DNS.
If Custom DNS - you will need to setup your DNS servers to do DNS forwarding and send requests for 'privatelink.windows.net' to Azure DNS. Only IPs that are registered with Azure will be authorized to query Azure DNS. If you're using Azure DNS it will start working.
If it doesn't resolve for you right away then you will have to check to see if the Private DNS Zone has a virtual network link that connects your VNETs.
Azure Private DNS
https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns
Private DNS Documentation:
https://learn.microsoft.com/en-us/azure/dns/private-dns-privatednszone
DNS Links Documentation:
https://learn.microsoft.com/en-us/azure/dns/private-dns-virtual-network-links#resolution-virtual-network

Unfortunately Private Endpoints are not supported with Elastic Jobs. You must enable "Allow Azure Services and resources to access this server" for Elastic Jobs to work.

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 Data Factory route to external SFTP without SHIR

ADF with AIR connected to external SFTP server to grab file. This SFTP have firewall that have to whitelist IP address where connection come from. Trafix should be routed via Managed NET private endpoint and then some how to NAT gateway and public IP.
Is it possible to implement such thing ?
We want to avoid using any IaaS/VMs.
• Yes, you surely can implement such thing in your Azure environment considering that the SFTP server from which you have to grab a file is also hosted in Azure protected by an Azure firewall or even if it is not and if the SFTP server is hosted in on-premises protected by a hardware firewall, then also the setup for implementing this is quite possible.
For the above purpose, you will have to deploy a private link service and a load balancer with public IP address enabled in your tenant. Also, ensure that the load balancer is hosted in a virtual network subnet created in the same region and resource group where Azure Data Factory with Azure Integrated runtime is deployed. Since you have already deployed the ADF with AIR in the managed virtual network with private endpoints, it is possible for this managed private endpoint in an approved state to send traffic to a given private link resource.
• Once you create a private endpoint connection, it is in a ‘Pending’ state unless approved by the resource owner. If the owner approves the connection, a private link is established. Otherwise, the private link won't be established. In either case, the managed private endpoint will be updated with the status of the connection. Once, the private endpoint is setup, then you can setup the load balancer with the SFTP server’s public IP address as the backend and the private endpoint of the ADF with AIR as the frontend for you to fetch the file from the SFTP server and initiate the connection from the ADF. Kindly refer to the below reference diagram and documentation link given for more information in this regard as to how to implement the said setup using the above stated Azure resources.
https://learn.microsoft.com/en-us/azure/data-factory/tutorial-managed-virtual-network-on-premise-sql-server
In the above link, you have to connect to an on-premises SQL server instead of a SFTP server and the ADF managed private endpoint is shown connecting to another allowed Azure service resources for which instead, in your case, you can directly connect it to the Private Link service deployed in as stated earlier.
I found two options to do this:
Run SHIR at VMSS with custom extention installation.
Run SHIR at Windows Container at AKS. However AKS use VMSS behind, so VMSS looks more simple for some cases.
My goal was avoid using IaaS services to connect to external (non-Azure) SFTP server.

How to connect to an Azure SQL Server using the PrivateLink IP

I have an Azure logical SQL server to which I added a Private Link, the NIC is attached to an existing vnet\subnet. Our company's VPN is linked to that vnet and I can see other devices on the private link's subnet but not the SQL Server.
The SQL Server is reachable on the public URL (temporarily for testing) but trying to ping or tracert the server with the private IP fails, I can ping and tracert to other VMs on the same subnet.
I'm not using a custom DNS zone because it's imperative that we configure it with the IP and I haven't made any changes to our company DNS (I'm expecting not to have to).
Other than creating the private link and attaching it to the SQL Server, what else needs to be done? What am I missing?
I'am working on the same Issue. It's still not solved yet but there are some steps you need to do.
For the Connectivity it's required to add a DNS, especially if you want to connect from the On-Prem. Azure has a default DNS-Solution for Azure-Resources. The Problem is: From On-Prem you can't access the default Azure-DNS-Service.
So you have to configure a DNS-Zone (in Azure or On-Prem).

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