Does Connection to Azure PostgreSQL via JDBC and Service Principal is supported?

Jomar Lorenzo 0 Reputation points
2025-12-17T14:53:10.7633333+00:00

Were still not able to connect to your Azure PostgreSQL database through your Data Collector JDBC connection using Service Principal and Client certificate instead of Client secret.

With these, we wanted to clarify if connecting to Azure PostgreSQL via JDBC and Service Principal is supported?

Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Manoj Kumar Boyini 1,890 Reputation points Microsoft External Staff Moderator
    2025-12-17T15:39:42.1233333+00:00

    Hi Jomar Lorenzo,

    It sounds like you're trying to connect to Azure PostgreSQL using JDBC with a Service Principal, and you’re specifically using a client certificate instead of a client secret. Here’s what you should know:

    Support for Service Principal Connections: Azure Database for PostgreSQL supports connections via Service Principal for both traditional and passwordless authentication, including JDBC. However, you need to ensure that your Service Principal is correctly configured and has the necessary permissions.

    Verify Configuration:

    • Make sure your Service Principal is set up according to the Azure documentation. You need to ensure it has admin permissions on the database.
      • Check that the client certificate is configured properly if you're opting not to use the client secret.
      Connection String: When using JDBC, your connection string needs to be correctly formatted. It generally looks like this:
            jdbc:postgresql://<your-server-name>.postgres.database.azure.com:5432/<your-database-name>?sslmode=require&user=<your-username>&password=<your-password>
      
      If you're using a Service Principal, ensure that you're getting an access token correctly, possibly through the Azure Identity library, and use that as your password. Troubleshooting Steps: Here are steps you might want to review:
      - Verify that you are using the correct Service Principal name.
      
         - Test your connection using a simple connection script to see if it works outside of your environment.
      
            - Check the relevant permissions on your Azure Portal related to the Service Principal.
      

    If you're still facing issues after these steps, please consider these follow-up questions to help narrow down the issue:

    • What specific error messages are you receiving when you attempt to connect?
    • Can you share more details about the exact setup of your Service Principal and client certificate?
    • Which JDBC driver version are you using?
    • Have you tried connecting using a different authentication method (like client secret) to see if the issue persists?

    Hope this helps you get connected!

    References


Your answer

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