Access Azure Storage Account via Private Link from a peered Virtual Network - azure-virtual-network

I have an Azure Storage Account with a private link associated to VNET1 / SUBNET11. Additionally I have a VM1 in VNET1 / SUBNET12. This works great - i.e. I can access the Storage Account from VM1 but not outside VNET1.
Now I peered VNET2 with VM2 in VNET2 / SUBNET21. Unfortunately I can't access the Storage Account from VM2.
What is the reason for that?

Obviously the private link set up works for VNET1. The reason why it did not work from VNET2 is that it is necessary to add an additional "Virtual Network Link" from the related Private DNS Zone to the peered virtual network (VNET2).
Establishing this link allows now resources in VNET2 to access the Private DNS Zone, what is necessary for the Storage Account access. See also https://learn.microsoft.com/en-us/azure/dns/private-dns-virtual-network-links).

Related

No access to Azure Storage Account which has virtual network only access, despite a succesful Point2site connection to that virtual network

I want to restrict access to my Azure storage account to selected networks only (please see image).
Current network restriction setting
My current set up is as follows:
I have an Azure Storage account, with blob containers and tables.
Only selected networks can access this storage account (please see the first image above). I've selected the gateway subnet (I've tried to add other subnets within the same virtual network, to no avail).
I have selected a virtual network call. All service endpoints for this network are set up correctly ('storage-service endpoint' is 'succesful'). The subnet involved is gateway subnet.
I also have a virtual gateway which is placed inside this virtual network. With (of course) the gateway subnet assigned to it.
Subnet endpoint permission
I have a point2site VPN connection (using Azure VPN client) to connect to this virtual network from my local machine (see image below).
This connection has been set up as well, using Active Directory as authentication method. All seems correctly working.
The virtual gateway to which the VPN connects, can see the active connection (see image below)
Obviously, I'm doing something wrong, so any help is very much welcome!
Regards,R.
VPN connection details
I have a point2site connection to the virtual network that is granted access to this storage account (see images below).
The point2site connection looks good (see image below), but I still can't access the storage account.
Current connection in azure VPN client
Current view of active connection to Virtual Gateway that connects to this Vnet.
Any help is much appreciated!
I tried to reproduce your scenario that can be possible with setting the private end point in storage account and azure VPN client.
you need to create and configure a Private End Point under the subnet you have the storage account exists.
Go to 'Private Endpoint Connection' under settings of storage account in azure portal as below:
Connected with Vnet using Azure VPN client .
Now you can map network drive on this pc using this format
\\Private IP Address or FDQN \Filesharename
For me there is one blockage.it error: Unable to reach the Azure storage account via port 445. I can’t add port 445 in my system if you have port number 445 you can be able to access the file share if not add port 445 so the SMB traffic over this port.
Note: Disable the firewall/ anti-virus temporarily installed on your computer.
Reference: https://learn.microsoft.com/en-us/azure/storage/files/storage-troubleshoot-windows-file-connection-problems

EF Core connect from Google Cloud Run to Google Cloud SQL

I have tried these:
Data Source=/cloudsql/*****:asia-southeast2:*****;Initial Catalog=*****;Integrated Security=False;User ID=sqlserver;Password=MyPassword0!;MultipleActiveResultSets=True
that /cloudsql/*****:asia-southeast2:***** is my instance connection name described in here.
I tried public IP too like this:
Data Source=***.***.***.***;Initial Catalog=*****;Integrated Security=False;User ID=sqlserver;Password=MyPassword0!;MultipleActiveResultSets=True
with IP address my SQL instance public IP, but it is not working.
I have enabled the sql instance connection from the Cloud Run:
How can I fix the connection string using EF Core?
This is the error I got:
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related
or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify
that the instance name is correct and that SQL Server is configured to
allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
You are trying to use Cloud SQL SQL server with Cloud Run. But if you have a look to the documentation, this connexion is not supported.
In reality, the connexion is supported, but Cloud Run service open a Unix socket to connect the SQL Server instance. And there is no SQL Server client compliant with Unix Socket and therefore, you can't access it.
To solve your issue, I recommend you to use the Private IP section of this page. You can also achieve the same configuration with the public IP (don't use a serverless VPC connector and go to your Cloud SQL instance, and authorized the network 0.0.0.0/0 to access to your instance), but, because you need to open broadly the authorized network, I don't recommend you this option, for security reason.
EDIT 1
Because of my bad english, let me explain more!!
The best way is to follow the documentation page: Connect Cloud SQL private IP to your VPC, use a serverless VPC connector with Cloud Run, and in your code you can use the private IP in your connection string to access the database.
But, you can also use the public IP, that I don't recommend (see below why), at least in its first naive use. In fact, you can use the pubic IP instead of the private IP in your code. Because you use the pubic IP, you no longer need the serverless VPC connector on your Cloud Run service (you don't use the VPC but the internet to reach the internet).
However, because you use the internet and Cloud Run is a multi-customer shared service, you don't know your source IP. On Cloud SQL, you need to allow any IP (0.0.0.0/0) in the authorized network section to access to your database, which is not a very secure configuration.
Alternatively, you can create a more complex configuration on Cloud Run to use securely the Cloud SQL public IP (but it becomes really complex). let me dig into it.
I said previously that Cloud Run is a shared service, and you don't manage the source IP when you initiate outgoing call (like connection to the database). It's true, but you can control that!
Firstly, you need (again) a serverless VPC connector on your Cloud Run. And you need to set your egress to ALL (route public and private traffic to the serverless VPC connector).
Then, create a Cloud NAT in your VPC and select, at least, your serverless VPC connector subnet to be NATed when going to the internet
Reserve a public IP on your Cloud NAT configuration
Now you have a public, static IP defined on your Cloud Run service. You can only grant it on your Cloud SQL authorized Network, to improve the security and don't let anybody access to your Cloud SQL instance.

Connection to Azure SQL database on Azure Private Link/Endpoint using Azure VPN Client not working

I'm trying to setup an Azure SQL database using P2S VPN for users who are remote working. They are using some applications like SSMS and Visual Studio that require access to the database. We allow them to connect by white listing their IP addresses but we would like to stop this and to use the deny public network access option on the SQL server on Azure.
Whenever I try to connect using SSMS I get the following message:
I've followed the steps outlined in the documentation and tutorials on MS Docs but I have not been able to get the private endpoint to work with the database.
I have created the virtual network gateway and connected it to Azure Active Directory and I can see the sessions being created by the users as they log in.
I have created the virtual network using the address range = 10.1.0.0/16 and the subnet address range = 10.1.0.0/24. I have attached the private endpoint connection to the Azure SQL server and added the virtual network to the firewall.
Is there some setting required to allow the user to connect to the database from their PC without whitelisting IP addresses?
WAY 1:
You may Use domain name instead of IP directly from your virtual
network. So, you need some service in Azure which can translate domain
name to IP.
It is necessary to properly configure your DNS settings to resolve the private endpoint IP address to the fully qualified domain name (FQDN) of the connection string.
Use a DNS forwarder for on-premises workloads to resolve the FQDN of a private endpoint, to resolve the Azure service public DNS zone in Azure.
A DNS forwarder is a Virtual Machine running on the Virtual Network
linked to the Private DNS Zone that can proxy DNS queries coming from
other Virtual Networks or from on-premises. This is required as the
query must be originated from the Virtual Network to Azure DNS.
.
Use the host file on a virtual machine to override the DNS: Azure
creates a canonical name DNS record (CNAME) on the public DNS. The
CNAME record redirects the resolution to the private domain name
(privatelink.database.windows.net). You can override the resolution
with the private IP address of your private
endpoints. See azure-provided-name-resolution.
References:
Azure services DNS zone configuration and
on-premises-workloads-using-a-dns-forwarder
Refer this for connectivity troubleshooting using Private Link
See how to resolve-azure-internal-dns-from-your-on-prem-network
WAY 2 :
You may go for SQL managed instance which is another Azure SQL
PaaS offering .It is deployed with in VNet with no public service
endpoints and uses root and client certificates to authenticate in
azure.
(Go for this when one prefers not to use Private endpoint:)
To configure P2S VPN using certificates Refer :
configure-p2s-vpn-using-certificates-and-connect-to-sql-managed-instance-from-on-premise-machine.
Other references:
DNS-Client-Configuration-Options
DNS-Integration-Scenarios
DNS-Scenario-Using-AD

Azure - Private Link Between Virtual Networks

I have two virtual networks: public and private. On the public vnet there is an app service. On the private vnet there is an azure sql database. The azure sql database has public access blocked and is exposing a private link. The two vnets are peered. The private dns zone for the private link has both vnets linked.
When I VPN to the private vnet I can connect to the private link no problem. When I try to connect via the app service I get an error:
SqlException: 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 (https://learn.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access). To connect to this server, use the Private Endpoint from inside your virtual network (https://learn.microsoft.com/azure/sql-database/sql-database-private-endpoint-overview#how-to-set-up-private-link-for-azure-sql-database).
It seems like the app service is using the public IP address (thus the error) as opposed to seeing the private IP address (via the private dns zone).
How can I set up the azure app service to connect via private link across vnets?
Update: My app service is using Docker. I ssh'ed into it and saw that the dns name was resolving to the public IP address. I temporarily added the IP to the hosts file (the private IP), but I still get the same error.
This smells more like a networking or DNS issue rather than specific to Private Link on the Azure SQL DB.
As you can SSH into your App container, can you try some network tests from there such as TRACERT to see whether it is resolving the private IP correctly and also has a suitable route in place between the virtual networks.
Haver you also checked NSGs on each virtual network to ensure that port 1433 is alloed to pass between them?
On the configuration page of your app service you need to add the following app settings:
WEBSITE_DNS_SERVER with value 168.63.129.16
WEBSITE_VNET_ROUTE_ALL with value 1

Deploying Azure application internally

Can anyone suggest some solution for this scenario?:
I have two resources deployed in a VNet: Application Gateway and a VM behind application gateway. (Application gateways in subnet1 and VM in subnet2) There's is no public ip associated with Application Gateway (internal app gateway with only private ip). I have automation scripts in storage account in another tenant and I need to be able to download those inside vm using azure cli. With the given architecture, I want to be able to download the scripts in the vm from storage account. Currently, if I run "az login" from VM, nothing happens. I found some help on Azure documentation :https://learn.microsoft.com/en-us/azure/application-gateway/configuration-overview#allow-application-gateway-access-to-a-few-source-ips but it's not helpful.
I have also attached network security group with allows VnetInbound for VM. In while architecture, I cannot use any public ip because of customer requirements and they do not want any connectivity to internet.
Any suggestions?
Thanks in advance!
Since Azure VM does not attach a public IP, the storage account does not directly communicate with your Azure VM over the Internet.
In this scenario, I would like to provide two suggestions:
The one is to use virtual network service endpoints, which allow you to secure Azure Storage accounts to your virtual networks, fully removing public internet access to these resources. You could create service endpoints for Microsoft.Storage in that VM subnet. You VM instance will access the storage account over the Azure backbone network but it has some limitations as below:
The virtual network where the endpoint is configured can be in the
same or different subscription than the Azure service resource. For
more information on permissions required for setting up endpoints and
securing Azure services, see Provisioning.
Virtual networks and Azure service resources can be in the same or
different subscriptions. If the virtual network and Azure service
resources are in different subscriptions, the resources must be under
the same Active Directory (AD) tenant.
Another suggestion is to use private endpoints for Azure Storage. You could create Private endpoint connections for the storage account in a VNet, then peer this VNet with the VNet where your Azure VM create.
For more references, you could get more details and steps on these blogs--https://stefanstranger.github.io/2019/11/03/UsingAzurePrivateLinkForStorageAccounts/
and
https://kvaes.wordpress.com/2019/03/10/hardening-your-azure-storage-account-by-using-service-endpoints/