How to allow remote connections to SQL server on an Azure VM through an Azure VPN

Kyle Sicard 20 Reputation points
2025-07-23T13:12:01.03+00:00

I have a Virtual machine on my azure network that is accessed by an Azure VPN via a virtual network gateway. I need to allow a user to connect to SQL server on that VM. I dont want to open 1433 and 1434 to the whole internet and the user does not have a static public IP address.

how can I allow only Azure VPN users to remotely connect to the SQL server?

SQL Server on Azure Virtual Machines
{count} votes

1 answer

Sort by: Most helpful
  1. Saraswathi Devadula 11,325 Reputation points Microsoft External Staff Moderator
    2025-07-23T13:24:36.19+00:00

    Hello Kyle Sicard
    By configuring the NSG to allow traffic on port 1433 only from the Azure VPN subnet, you can securely allow users to connect to the SQL Server without exposing it to the public internet. This setup ensures that only authenticated VPN users can access the SQL Server, maintaining security while providing necessary access. 
    Reference document: https://learn.microsoft.com/en-us/azure/virtual-network/manage-network-security-group?tabs=network-security-group-portal

    When users connect to the Azure VPN via the Point-to-Site (P2S) configuration, they are assigned IPs from a VPN address pool (usually something like 172.16.0.0/24).

    You can find or configure this in: 

    Azure Portal → Virtual Network Gateway → Point-to-site configuration → Address pool

    Reference document: https://techcommunity.microsoft.com/blog/itopstalkblog/step-by-step-creating-an-azure-point-to-site-vpn/326264

    **Authentications:

    **Please be informed that Azure SQL server doesn't support Windows authentication. It will work for SQL managed instance.

    Microsoft Entra ID supports azure sql server to connect.

    But it depends on how you configured the server. If you have selected both SQL and Microsoft Entra authentication, then it will work as shown below, User's image

    If you select only sql authentication, then you can to set your current Azure AD user as the Azure SQL Admin for your database. Follow the steps below:

    Navigate to Your Azure SQL Server:

    Search for and select your Azure SQL Server.

    1. Set Azure AD Admin:
      • In the left-hand menu, under Settings, click on Microsoft Entra ID.
      • Select Support Only Microsoft Entra authentication for this server to ensures no one can access the database server using SQL login credentials.
        • Click on Set admin.Copy
                    - In the Add admin pane, search for your user account.
          
          
      • Select your account and click Select.
        - This will set your user as a database admin and allow it to login using Microsoft Entra authentication.
        
           - Click on **Save**.
        
                  
        

    User's image

    Note: Make sure you uncheck that box, as this will disable the SQL authentication.

    Reference document: https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/configure-azure-ad-authentication-for-sql-vm?view=azuresql&tabs=azure-portal

    https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-overview?view=azuresql

    https://techcommunity.microsoft.com/blog/fasttrackforazureblog/connecting-to-azure-sql-database-using-sqlalchemy-and-microsoft-entra-authentica/4259772

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.